Get the tools you need to learn Java skills fast!
Video tutorials, eBooks, hands-on lab exercises, sample code.
Get started
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 The Software Craftsman this week in the Agile 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: 62317
    
  68

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: 62317
    
  68

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?
 
Don't get me started about those stupid light bulbs.
 
subject: How to handle jsp's not being opened when we paste the url in another browser