aspose file tools*
The moose likes Servlets and the fly likes jsp forwarding to a target frame 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 "jsp forwarding to a target frame" Watch "jsp forwarding to a target frame" New topic
Author

jsp forwarding to a target frame

Ezra Exposito
Ranch Hand

Joined: Apr 26, 2001
Posts: 34
I have some pages with frames in it. In addition, I have a session manager running to validate users and I want to forward them to an invalid user page in the top frame if they haven't logged in. How can I do this using the <jsp:forward> tag ?
Thanks,
E.E.
Desai Sandeep
Ranch Hand

Joined: Apr 02, 2001
Posts: 1157
Hi,
Please find the following piece of code.

I think your SessionManager would be like the LoginManager that I have shown in the above code.You can check/validate the status of the user , before forwarding it to the desired page.
Hope this helps.
Regards,

------------------
Sandeep Desai
vgdesai@bom3.vsnl.net.in

  1. Sun Certified Java Programmer Scored 93 per cent
  2. Oracle JDeveloper Rel. 3.0 - Develop Database Applications with Java Scored 56 out of 59
  3. IBM Enterprise Connectivity with J2EE Scored 72 per cent
  4. Enterprise Development on the Oracle Internet Platform Scored 44 out of 56


<b>Sandeep</b> <br /> <br /><b>Sun Certified Programmer for Java 2 Platform</b><br /> <br /><b>Oracle Certified Solution Developer - JDeveloper</b><br /><b>-- Oracle JDeveloper Rel. 3.0 - Develop Database Applications with Java </b><br /><b>-- Object-Oriented Analysis and Design with UML</b><br /> <br /><b>Oracle Certified Enterprise Developer - Oracle Internet Platform</b><br /><b>-- Enterprise Connectivity with J2EE </b><br /><b>-- Enterprise Development on the Oracle Internet Platform </b>
Ezra Exposito
Ranch Hand

Joined: Apr 26, 2001
Posts: 34
Originally posted by Desai Sandeep:
[B]Hi,
Please find the following piece of code.

I think your SessionManager would be like the LoginManager that I have shown in the above code.You can check/validate the status of the user , before forwarding it to the desired page.
Hope this helps.
Regards,
[/B]

My session manager does look something like that. The problem
is that the site uses two frames, one for navigation and the other to display the page. I would like the page that I am forwarding to appear in the browser in the top window so it is the only page showing eliminating the navigation frame.
Desai Sandeep
Ranch Hand

Joined: Apr 02, 2001
Posts: 1157
Hello,

I would like the page that I am forwarding to appear in the browser in the top window so it is the only page showing eliminating the navigation frame.

I suppose the above logic could be put in the forwarded page.You can describe the layout the way you want in that page.
Hope this helps.
Regards,


------------------
Sandeep Desai
vgdesai@bom3.vsnl.net.in

  1. Sun Certified Java Programmer Scored 93 per cent
  2. Oracle JDeveloper Rel. 3.0 - Develop Database Applications with Java Scored 56 out of 59
  3. IBM Enterprise Connectivity with J2EE Scored 72 per cent
  4. Enterprise Development on the Oracle Internet Platform Scored 44 out of 56
maha anna
Ranch Hand

Joined: Jan 31, 2000
Posts: 1467
Ezra,
Use META tag trick in your forwarded page to tell the browser to show the results in one single top window. Give it a try. I think it will work. Haven't tested yet.
regds
maha anna
Got this info from an online tutorial.


[This message has been edited by maha anna (edited April 26, 2001).]
Andrew Shafer
Ranch Hand

Joined: Jan 19, 2001
Posts: 338

If I understand correctly, you have a top frame that is the navigation and then some other stuff in the bottom.
You want the top frame to be replaced with the not authorized page. You don't want it to load to the top window, but the top frame correct?
I'm not positive, but I imagine your login is in the lower frame and not in the top one or you wouldn't have this problem.
When using frames, each HTML frame is a seperate page request. Since HTTP is stateless, managing state between frames is difficult. Also, one way or another the window or target frame gets determined on the client side.
I tried searching around to see if there was a nice answer to this but couldn't find one. You might look into the <meta> approach, maybe you can put the name of the target frame instead of _top and it will work. I haven't tried anything but there might be some send redirect/javascript combo.
It would be sweet if you could do something like:

or similar with the jsp:forward, but right now it doesn't seem that will work.
I'll look at some books later and see what I can find.


!_I_Know_Kung_Fu_!
maha anna
Ranch Hand

Joined: Jan 31, 2000
Posts: 1467
Ezra,
Please have a look at the demo version of my 'Resource Management' web application.
http://www.webappcabaret.com/maha/index.jsp
I have top (Navigation) and botton content frames. User can always see the top-frame menu options. But he/she can go into those options only when successfully logged into the system. If he/she fails to login, any response/message from server side will appear inside the content frame. You can play around this online demo to get a hang of it.
regds
maha anna
Ezra Exposito
Ranch Hand

Joined: Apr 26, 2001
Posts: 34
Originally posted by maha anna:
[B]Ezra,
Use META tag trick in your forwarded page to tell the browser to show the results in one single top window. Give it a try. I think it will work. Haven't tested yet.
regds
maha anna
Got this info from an online tutorial.

I tried using the meta tag but it didn't work.
Thanks for trying...
E.E.
[This message has been edited by maha anna (edited April 26, 2001).][/B]

Ezra Exposito
Ranch Hand

Joined: Apr 26, 2001
Posts: 34
Originally posted by maha anna:
Ezra,
Please have a look at the demo version of my 'Resource Management' web application.
http://www.webappcabaret.com/maha/index.jsp
I have top (Navigation) and botton content frames. User can always see the top-frame menu options. But he/she can go into those options only when successfully logged into the system. If he/she fails to login, any response/message from server side will appear inside the content frame. You can play around this online demo to get a hang of it.
regds
maha anna

You are on the right track with what I am trying to do. Your
login page appears in the bottom frame if they are not valid
users. I would like my login page to be the only page showing.
E.E.
Ezra Exposito
Ranch Hand

Joined: Apr 26, 2001
Posts: 34
Originally posted by Andrew Shafer:
[B]
If I understand correctly, you have a top frame that is the navigation and then some other stuff in the bottom.
You want the top frame to be replaced with the not authorized page. You don't want it to load to the top window, but the top frame correct?
I'm not positive, but I imagine your login is in the lower frame and not in the top one or you wouldn't have this problem.
When using frames, each HTML frame is a seperate page request. Since HTTP is stateless, managing state between frames is difficult. Also, one way or another the window or target frame gets determined on the client side.
I tried searching around to see if there was a nice answer to this but couldn't find one. You might look into the <meta> approach, maybe you can put the name of the target frame instead of _top and it will work. I haven't tried anything but there might be some send redirect/javascript combo.
It would be sweet if you could do something like:

or similar with the jsp:forward, but right now it doesn't seem that will work.
I'll look at some books later and see what I can find.[/B]

That would be really sweet if they had that, it would give
so much flexibility. Is there any way I could use the actual
url like "some.jsp?target=_top" ? I tried this but it didn't
work. I was wondering if there some special syntax that needs
to be followed to make something like this work.
E.E.
prabhat kumar
Ranch Hand

Joined: Apr 11, 2001
Posts: 114
suppose u have one page with two frames ..
named ..
frame1
frame2 --
now say ..frame2 has a form ...
like this ..
<form method="post" action="some.jsp" >
if we want that after processing some.jsp shud show results in
frame1
then we can modify the form tag like this
<form method="post" action="some.jsp" target="frame1">
i hope it will be of some help

maha anna
Ranch Hand

Joined: Jan 31, 2000
Posts: 1467
Ezra,
I would like to clear this first.
1. User has to log into your system first in order to use your appln further.
2. How do they first get to login page? Is it like http://yourDomain.com/applnName/login.html ?
If so, how does this page look? 2 frames or single page?
3. You said, you have 2 frames top (all nav links) and bottom (contents). Users get to see those top and bottom frames AFTER they successfully login, or login is one of the option links in your top frame?
Please explain, the anticipated use case in little more detail.
Before I confuse you more, please clear these doubts.
regds
maha anna
[This message has been edited by maha anna (edited April 27, 2001).]
Ezra Exposito
Ranch Hand

Joined: Apr 26, 2001
Posts: 34
Originally posted by maha anna:
Ezra,
I would like to clear this first.
1. User has to log into your system first in order to use your appln further.
2. How do they first get to login page? Is it like http://yourDomain.com/applnName/login.html ?
If so, how does this page look? 2 frames or single page?
3. You said, you have 2 frames top (all nav links) and bottom (contents). Users get to see those top and bottom frames AFTER they successfully login, or login is one of the option links in your top frame?
Please explain, the anticipated use case in little more detail.
Before I confuse you more, please clear these doubts.
regds
maha anna
[This message has been edited by maha anna (edited April 27, 2001).]

My login screen does not have any frames in it. The frames appear
after someone logs in. I am trying to send the user back to the
login screen after some inactivity using the <jsp:forward> tag.
Josh Johnson
Greenhorn

Joined: Jan 15, 2001
Posts: 20
I have encountered the exact same problem that you are having with a web application that I worked on. Here is the way I handled the situation, but this does not really solve the problem.
When it has been determined that the user has not logged in (or that the session has timed out.) I redirected the user to a simple html page that said:

"You have not logged in or your session has timed out.
Click here to go to the login page."
This message appeared within the content frame. The link in this page (that pointed to the login page) specified the entire browser window (or "top" frame) as its target. So when the user clicked on the link to the login page, the login page was displayed in the entire browser window.
I far as I know (and I'm no expert), once the user clicks on a link within a frame, there is no way to make the server's response appear in a frame other than the frame determined by the target attribute (or lack of a target attribute) in the a href tag. I don't know of any way the server can dynamically control which frame it's response it displayed in.
[This message has been edited by Josh Johnson (edited April 30, 2001).]
[This message has been edited by Josh Johnson (edited April 30, 2001).]
maha anna
Ranch Hand

Joined: Jan 31, 2000
Posts: 1467
Ezra,
Josh' idea is good. Here is another idea. Slightly change the Login.html itself to include an "onLoad" javascript fn, which will make this loagin page as top/only page on screen. In other words, it will break out of any frames. For testing purposes I hard-coded the url. You can change it to include dynamic domain,servertcontext etc using properties file or web.xml file.
Of course it is a Javascript solution. Depending upon your requirement you choose either Josh's or this.

regds
maha anna
Ezra Exposito
Ranch Hand

Joined: Apr 26, 2001
Posts: 34
Originally posted by maha anna:
[B]Ezra,
Josh' idea is good. Here is another idea. Slightly change the Login.html itself to include an "onLoad" javascript fn, which will make this loagin page as top/only page on screen. In other words, it will break out of any frames. For testing purposes I hard-coded the url. You can change it to include dynamic domain,servertcontext etc using properties file or web.xml file.
Of course it is a Javascript solution. Depending upon your requirement you choose either Josh's or this.

regds
maha anna[/B]

Thank you very much Maha ! This worked very well.
I really appreciate your time and effort
to help me out.
E.E.
maha anna
Ranch Hand

Joined: Jan 31, 2000
Posts: 1467
Glad to know that we finally got a solution. ( finally understood what you really wanted! )
regds
maha anna
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jsp forwarding to a target frame