• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Servlet and Frame Problem

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you try posting the name of the bottom frame to the servlet.
I think that would help
Napa
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your help guys, I'll try out that code and get back.
Thanks again,
Mike
 
Did you ever grow anything in the garden of your mind? - Fred Rogers. Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic