Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet and Frame Problem

 
Mike Br
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you try posting the name of the bottom frame to the servlet.
I think that would help
Napa
 
Barron Greig
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your help guys, I'll try out that code and get back.
Thanks again,
Mike
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic