I created two frames which respectively contain two links.
When the first frame gets clicked, I would like to display a JSP page in the second frame.
But I can't get it to work. When the first frame gets clicked, it opens the JSP page in a new window.
I paste some of my code.
This is my main.jsp
<html>
<frameset cols="50%,50%">
<frame src="frame1.jsp">
<frame src="frame2.jsp">
</frameset>
</html>
frame1.jsp
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Frame 1 with links</title>
</head>
<body>
<body bgcolor="lightBlue">
<h2>Java Tutorial</h2>
<a href="subframe1.jsp" target="frame2.jsp"> tracking system</a>
<a href="subframe2.jsp" target="frame2.jsp">data information</a>
</body>
</html>
frame2.jsp
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>
<body>
</body>
</html>
subframe1.jsp
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form action="insertData.jsp" action="post" >
DATA ID:<input type="text" name="data_id"><br>
East:<input type="text" name="east"><br>
North:<input type="text" name="north"><br>
<input type="submit" value="Save">
</form>
</body>
</html>
How can I fix that?
First I must say - Framesets are bad, if you can avoid using them then do so.
That said, the target value of your links needs to be a framename.
You have not named your frames, you need to specify a name attribute.
So you need to change your frameset to look more like:
<frameset cols="50%,50%">
<frame name="frame1" src="frame1.jsp">
<frame name="frame2" src="frame2.jsp">
</frameset>
and then change your links accordingly:
<a href="subframe1.jsp" target="frame2"> tracking system</a>
<a href="subframe2.jsp" target="frame2">data information</a>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With