Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Accessing jsp's directly

 
Corey Harden
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3381
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Corey Harden
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Corey Harden
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, that's exactly how I have it set up. Thanks for the help! I'll look into how to setup the web flow.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic