Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Deny JSP straight access but use them as forwards. How?

 
Grigory O. Ptashko
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello.

I need to do the following scheme: I want all the URLs to be handled by one servlet, e.g /one or /one/two or /one/two/three.do to be handled by only one servlet, say MainServlet. And I want to deny access to JSPs but use them only as forwards from my servlet. E.g. when a user types http://myserver.com/some.jsp, he/she get 404 not found, or forbidden, whatever. But he/she must not straight access any JSP.

How must I configure my webapp?

Thank you.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can put them under the WEB-INF directory which can't be accessed directly from a browser.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64700
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I place all of my JSPs -- except those that must be able to be accessed directly, usually very few -- in a folder structure rooted at WEB-INF/pages.
[ January 26, 2006: Message edited by: Bear Bibeault ]
 
Grigory O. Ptashko
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh, that's a great idea. I've just tried it out and it worked
I want to ask whether it is a normal practice to like that but I saw the second reply and changed my mind

Thanks guys.

But still, what <url-mapping> should I specify so that all the requests to my server are handled only by MainServlet?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64700
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Grigory O. Ptashko:

But still, what <url-mapping> should I specify so that all the requests to my server are handled only by MainServlet?


Actually you probably do not want all requests to be routed to the front controller unless the front controller servlet is going to handle all requests including image file, script files and style sheets.
[ January 26, 2006: Message edited by: Bear Bibeault ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64700
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Satou kurinosuke:
<url-pattern>/*</url-pattern>


Like I said, that will capture all requests. Probably not what you want to do.

More common: something like /someprefix/*.
 
Grigory O. Ptashko
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear,

yes, that's what I need. I'll make it with some prefix. Thanks for your comment.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic