File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Spring and the fly likes Accessing jsp's directly Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Accessing jsp Watch "Accessing jsp New topic
Author

Accessing jsp's directly

Corey Harden
Greenhorn

Joined: Apr 27, 2009
Posts: 11
I've created an application with the Spring Framework. In my directory structure, I have a jsp folder (in which all of my jsp's are located) sitting inside of the WEB-INF folder with a redirect outside of the WEB-INF folder so that the jsp's can be accessed. The problem that I am having is that even though the jsp's are in WEB-INF, they are still accessible directly through their url. Maybe I've done something wrong, but I thought you should only be able to access them from another jsp.
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3344

Corey Harden wrote:I've created an application with the Spring Framework. In my directory structure, I have a jsp folder (in which all of my jsp's are located) sitting inside of the WEB-INF folder with a redirect outside of the WEB-INF folder so that the jsp's can be accessed. The problem that I am having is that even though the jsp's are in WEB-INF, they are still accessible directly through their url. Maybe I've done something wrong, but I thought you should only be able to access them from another jsp.


What do you mean by "inside of the WEB-INF folder with a redirect outside of the WEB-INF folder so that the jsp's can be accessed"?

Generally the contents inside the WEB-INF folder are *NOT* exposed outside directly and hence they are put in.


Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
Corey Harden
Greenhorn

Joined: Apr 27, 2009
Posts: 11
The redirect is on the same level, inside of the WEB folder, as the WEB-INF folder. When users type in the url to the website (ie. www.yahoo.com), they are redirected to the index/home page that sits inside of the WEB-INF folder. So the only way I expected the pages inside of WEB-INF to be accessed was through ie. www.yahoo.com but this is not the case. If I type ie. www.yahoo.com/payment.htm, I'll be taken to the payment page, etc.
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

You aren't accessing the JSP directly - "www.yahoo.com/payment.htm" doesn't end in .jsp.

It sounds like you've set up a view resolver in Spring, something like this -


This prevents the JSPs from being accessed outside of a defined *Controller* - so if you have a controller defined like this -


And inside PaymentController it forwards to the "payment" view. Then what happens is when enter the url "www.yahoo.com/payment.htm", Spring will process the PaymentController, which uses the /WEB-INF/jsp/payment.jsp as it's view.

The view resolver does not prevent users from accessing pages "out of order" - to do that, you'll need to use a wizard form controller or (even better) Spring Web Flow.

-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Corey Harden
Greenhorn

Joined: Apr 27, 2009
Posts: 11
Yes, that's exactly how I have it set up. Thanks for the help! I'll look into how to setup the web flow.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Accessing jsp's directly
 
Similar Threads
creating website basic question
Accessing images under WEB-INF
Include Jsp in Jsp
is WEB-INF and web-inf same??
J2EE war structure