File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Servlet and Frame Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet and Frame Problem" Watch "Servlet and Frame Problem" New topic
Author

Servlet and Frame Problem

Mike Br
Greenhorn

Joined: Nov 22, 2001
Posts: 20
Hiya, can anyone help. I have two frames on my page, a JSP page on the bottom and a Flash Movie on the top which posts data into a servlet. The servlet receives the data fine. I then use a forward statement in the servlet to pass the recived data into the JSP page (on the bottom frame). Problem is, the servlet output loads the JSP page into my top frame (over the Flash Movie). How can I tell the servlet to post to the bottom frame (where the JSP page is sitting waiting!!). Is this a javascript issue??
Any help much appreciated.
Mike
Napa Sreedhar
Ranch Hand

Joined: Jan 29, 2002
Posts: 62
Did you try posting the name of the bottom frame to the servlet.
I think that would help
Napa
Barron Greig
Greenhorn

Joined: Jan 26, 2002
Posts: 8
I don't think there is a way of passing frame info directly to the HttpServletResponse. You do have to use a bit of Javascript. I wrote a support method for loading into a frame from servlet code. It's used something like
reloadFrame(response, "/myapp/Target.jsp");
In my code, the frame MUST have been given the same name as the jsp file without extension. For the above example, the frame could have been declared something like
<IFRAME name="Target" SRC="/myapp/Target.jsp"
scrolling=no></IFRAME>
The method itself:
protected void reloadFrame(HttpServletResponse response,
String frameURL)
throws IOException {
ServletOutputStream out = response.getOutputStream();
String frameName = (new File(frameURL)).getName();
StringTokenizer stok = new StringTokenizer(frameName, ".");
frameName = stok.nextToken();
out.println("<HTML><BODY>");
out.println("<SCRIPT LANGUAGE=\"JavaScript\">");
out.println("<!--");
out.println("frs = top.frames");
out.println("for (i = 0;i < frs.length;i++) {");
out.println(" if (frs[i].name == \"" + frameName + "\") {");
out.println(" top.frames[i].location.href=\"" + frameURL + "\"");
out.println(" break");
out.println(" }");
out.println("}");
out.println("// -->");
out.println("</SCRIPT>");
outputNoScript(out);
out.println("</BODY></HTML>");
}
Mike Br
Greenhorn

Joined: Nov 22, 2001
Posts: 20
Thanks for your help guys, I'll try out that code and get back.
Thanks again,
Mike
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Servlet and Frame Problem
 
Similar Threads
Removing Top Frame Leaving Bottom Frame Intact
Want to refresh Top jsp(Interesting Question)
Access Denied error in Javascript
Removing Top Frame Leaving Bottom Frame Intact
Frames