aspose file tools*
The moose likes Servlets and the fly likes How to set frame target in Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to set frame target in Servlet" Watch "How to set frame target in Servlet" New topic
Author

How to set frame target in Servlet

Huaxing Wu
Greenhorn

Joined: Sep 07, 2001
Posts: 1
We have a JSP that is in a Frame that allows a user to login. If the user successfully logs in we want to replace the frameset with a new frameset, and if not successful we want to stay with the same frameset.
The JSP post a request to a servlet, and the servlet will determine if the user logged in or not. If the user logged in we need to set "target=_top", and if not successfully set "target=text". How do you do this in the servlet?
Thanks
chanoch wiggers
Author
Ranch Hand

Joined: May 24, 2001
Posts: 245
the only way I can think to do this doesnt have the servlet in the picture at all. Basically, if the servlet successfully logs the user in, it should return an HTML page that includes a javascript in it which checks if the current frame is the top one and reassigns the url for the top frame if not,
I think this goes something like:
if(self.url != top.url)
top.url = self.url
or something similar. I think you get the point. It sounds like the site needs rearchitecting though, I cant think of a reason to need to do what you are doing. The above solution would result in a double hit each tiem the user logs in, once to log in and return the appropriate page, and then a second time to return the page as a top level frame. On the other hand, this used to be quite common (despite the double hits at the beginning) to stop people leeching your site by having sites that were nothing but a two frame site with an advert in the first frame and someone elses site in the other.

chanoch<p><a href="http://www.amazon.com/exec/obidos/ASIN/1861007736/" target="_blank" rel="nofollow">Author of Professional Apache Tomcat</a></p>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to set frame target in Servlet