Win a copy of Transfer Learning for Natural Language Processing (MEAP) this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Paul Clapham
  • Devaka Cooray
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Liutauras Vilda
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Piet Souris
Bartenders:
  • salvin francis
  • Carey Brown
  • Frits Walraven

Accessing jsp's directly

 
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.
 
Ranch Hand
Posts: 3389
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.
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • 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.
 
Acetylsalicylic acid is aspirin. This could be handy too:
Two software engineers solve most of the world's problems in one K&R sized book
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic