This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes JSP and the fly likes How to handle jsp's not being opened when we paste the url in another browser Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "How to handle jsp Watch "How to handle jsp New topic
Author

How to handle jsp's not being opened when we paste the url in another browser

ravisha andar
Ranch Hand

Joined: Feb 25, 2011
Posts: 55
Hii All,

SUppose i have a url to a jsp that is i am redirecting to a jsp from my servlet (the url will we displayed on the browser as http://abc.com/jsp/test.jsp)
If I copy the url and pate in other browser the page opens which actually should not happen
I handle this by using a session variable
Is there any better way to do it.

Any Help is highy appreciated !!!

Thanks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61456
    
  67

JSPs should never be directly addressable. The should be placed in a folder under WEB-INF so that they cannot be directly served.

You should be forwarding, not redirecting to the JSP from its controller.

Please read this article for more info.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
ravisha andar
Ranch Hand

Joined: Feb 25, 2011
Posts: 55
Thanks.

What is the advantage of forwarding over redirecting.

One more question : How about a servlet
if I paste http://abc.com/action.do( for example a file download servlet) in any browser the code(file download) executes.

How do i prevent it ?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61456
    
  67

ravisha andar wrote:What is the advantage of forwarding over redirecting.

Did you read the article? If you did, what part of the Page Controller pattern confused you? If you didn't, then read it.

How do i prevent it ?

You don't.

What actual problem are you trying to address?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to handle jsp's not being opened when we paste the url in another browser