6

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?

Peter O.
  • 32,158
  • 14
  • 82
  • 96
Vidya
  • 698
  • 2
  • 12
  • 21

1 Answers1

1

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>
Community
  • 1
  • 1
Mark McLaren
  • 11,470
  • 2
  • 48
  • 79
  • Sir thanks for the fix. Its working now. I would like to know why framesets are bad? And how do I avoid them – Vidya Feb 13 '14 at 17:22
  • I made "Framesets are bad" a link, scratch the surface and you will find many reasons for not using Framesets. It looks like you are developing a two panel interface maybe an jQuery/AJAX solution would work better for you? (With AJAX you could provide better error checking when you load the data, something that is very difficult to do with framesets etc.) – Mark McLaren Feb 13 '14 at 17:25