Placement of jsp files

J

James Yong

Hi,

Is it possible to place the jsp files inside WEB-INF folder in a web
environment and called by the RequestDepatcher?
I am using Tomcat.

Thanks and regards,
james
 
T

Thomas Hawtin

James said:
Is it possible to place the jsp files inside WEB-INF folder in a web
environment and called by the RequestDepatcher?

Yup. It's the preferred way of doing it.

Some early broken web servers (WebLogic?) did not permit it.

Tom Hawtin
 
C

Chris Smith

James Yong said:
Is it possible to place the jsp files inside WEB-INF folder in a web
environment and called by the RequestDepatcher?
I am using Tomcat.

Yes, that is possible. If you do so, then the JSPs will not be
dispatched in direct response to a URL. You will need to forward to
them using RequestDispatcher in order to use them. That's okay, because
chances are you don't want to dispatch directly to JSP files anyway, if
you're designing well.

Note that this creates some problems with references to auxiliary files
such as images, stylesheets, etc. They can NOT be placed inside the
WEB-INF directory, or they won't be served to a web browser that
requests them. The problem can be solved by moving these files outside
of WEB-INF, but many development tools aren't cooperative with this
idea. I've also seen this problem solved by writing code in servlets to
serve those auxiliary files, but that gets messy.

--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
G

Guest

jsp file forbid that Depatcher into WEB-INF. but why not servlet
RequestDepatcher accessing in?
 
J

James Yong

Thomas Hawtin said:
Yup. It's the preferred way of doing it.

Some early broken web servers (WebLogic?) did not permit it.

Tom Hawtin

Thanks Tom for the reply. Btw, I am using Tomcat.
 
J

James Yong

Chris Smith said:
Yes, that is possible. If you do so, then the JSPs will not be
dispatched in direct response to a URL. You will need to forward to
them using RequestDispatcher in order to use them. That's okay, because
chances are you don't want to dispatch directly to JSP files anyway, if
you're designing well.

Note that this creates some problems with references to auxiliary files
such as images, stylesheets, etc. They can NOT be placed inside the
WEB-INF directory, or they won't be served to a web browser that
requests them. The problem can be solved by moving these files outside
of WEB-INF, but many development tools aren't cooperative with this
idea. I've also seen this problem solved by writing code in servlets to
serve those auxiliary files, but that gets messy.

--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation

Thanks Chris. Your explanation helps alot. Yes, the jsp files isn't called
directly.

Regards,
James
 
B

Babu Kalakrishnan

Chris said:
Yes, that is possible. If you do so, then the JSPs will not be
dispatched in direct response to a URL. You will need to forward to
them using RequestDispatcher in order to use them. That's okay, because
chances are you don't want to dispatch directly to JSP files anyway, if
you're designing well.

Note that this creates some problems with references to auxiliary files
such as images, stylesheets, etc. They can NOT be placed inside the
WEB-INF directory, or they won't be served to a web browser that
requests them. The problem can be solved by moving these files outside
of WEB-INF, but many development tools aren't cooperative with this
idea. I've also seen this problem solved by writing code in servlets to
serve those auxiliary files, but that gets messy.

I don't see why that should really create too much of a problem. As long
as the application is aware of the URL that is used by the browser to
access these resources, one could specify the static resources as
relative links w.r.t. to that URL. After all the browser doesn't know
that the real JSP file fas been served from behind the WEB-INF barrier,
and it can only resolve the link against the requested URL.

BK
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,434
Messages
2,571,691
Members
48,796
Latest member
Greg L.

Latest Threads

Top