This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan 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 Android Security Essentials Live Lessons this week in the Android 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: 60810
    
  65

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: 60810
    
  65

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
 
Similar Threads
Security Related Error in Servlet Application
How to Handle back button
Doubt in Cookies
Use jsp for 404 pg Sun One Web Server
Refresh Problem : same action gets called