tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daryl Handley" <darylhandle...@yahoo.com>
Subject RE: Forward to JSP from Servlet
Date Fri, 16 May 2003 22:08:44 GMT
What I ended up doing (and it saatisfies my requirements of being simple yet
without hard coding) is setting up my directorys for resources at the root
of the web app rather than within the jsp directory.

So at the root of my web app, I have the following sub directorys.

jsp
html
images
styles

Within my JSPs I have set up the URL's like this.

<IMG src="../images/image_name.html">

This works with the servlets as well since the browsers reference is

http://myDomain/myApp/servlet/myServlet

Thus when I forward to the jsp it will look for the resources at the root of
the web app (right where I left them).

Not sure if that's what you meant by "relative to the path of the servlet",
but cheers to all that helped.

Daryl




-----Original Message-----
From: mike jackson [mailto:mjackson@cdi-hq.com]
Sent: Friday, May 16, 2003 8:43 AM
To: 'Tomcat Users List'
Subject: RE: Forward to JSP from Servlet


Usually I end up setting up all of the relative paths for images and
whatnot relative to the path of the servlet.  However if you don't want
to do this, another good alternative is to map the servlet to the same
relative path as the jsp.  So if the jsp is going to be at
/OnlineStore/jsp/file.jsp, then in your web.xml you'd have a:

	<servlet-mapping>
		<servlet-name>foo</servlet-name>
		<url-pattern>/OnlineStore/jsp/foo</url-pattern>
	</servlet-mapping>

When you reference "foo" within the /OnlineStore/jsp it'll have the same
relative path as the jsp file.

--mikej
-=------
mike jackson
mjackson@cdi-hq.com



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message