Two Laptop Bag*
The moose likes Servlets and the fly likes Two different servlets to write to two frames in a frameset Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Two different servlets to write to two frames in a frameset" Watch "Two different servlets to write to two frames in a frameset" New topic
Author

Two different servlets to write to two frames in a frameset

Sue Stephen
Greenhorn

Joined: May 04, 2004
Posts: 11
Hi,
I have a frameset that has two frames. Each frame should receive dynamic data from the server side. So I use Servlet0 to print the frameset to the client, Servlet1 and Servlet2 to print data to Frame1 and Frame2 within the frameset separately:
-------------------
In Servlet0:
.............
buffer.append("<frameset cols=\"400,*\" frameborder=\"YES\" border=\"0\" framespacing=\"0\">");
buffer.append("<frame src=\"Servlet1\" name=\"Frame1\" scrolling=\"YES\" noresize>");
buffer.append("<frame src=\"Servlet2\" name=\"Frame2\">");
buffer.append("</frameset>");
writer.println(buffer.toString());
......

In Servlet1:
I print some links which can retrieve data from the server through calling Servlet0 again
..........
buffer.append("<a href = \"Servlet0\">link1</a>");
writer.println(buffer.toString());
..........

In Servlet2:
I need to print some data depending on link1, which means it can be different each time user activates a different link.
..........
buffer.append("some data");
writer.println(buffer.toString());
..........

The problem I encounter now is:
When I call Servlet0, Frame1 can show correct information each time, but Frame2 only shows correct information for the very first time and does not change to show correct information even the user click a different link in Frame1. However, Servlet2 (which writes to Frame2) collects correct information each time.

Could anyone give some suggestion? I use Tomcat 4 to test my application. Thank you for your help.

Sue
Natarajan Shankar
Ranch Hand

Joined: Jun 10, 2004
Posts: 53
Hi Sue,
I hope you have tried by clearing the buffer before writing. If servlet-2 able to receive retrieve proper info then it should be able to write in HTML. Hope buffering might be also an issue.


Best Regards<br />N.Shankar<br />SCJP, SCWCD
Sue Stephen
Greenhorn

Joined: May 04, 2004
Posts: 11
Hi Natarajan,
Could you give some suggestions as how to clear the buffer? I have tried:
to change Servlet2 to:
.......
buffer.append("some data");
writer.println(buffer.toString());
response.flushBuffer();
writer.close();
........

Thank you.

Sue
Sue Stephen
Greenhorn

Joined: May 04, 2004
Posts: 11
Hi,
I have solved the problem. I should have added a "target=_top" to each link.

Sue
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Two different servlets to write to two frames in a frameset