RE: offtopic: Path issues
I don't see this as a spec bug, I think it's quite deliberate. Sometimes you need to redirect to sth outside the web app. What'd be the point of having sendRedirect() duplicate the functionality of the RequestDispatcher? /Manne NOTE: All JSP commands are relative to the web app root EXCEPT response.sendRedirect() which is relative to the host (stupid spec bug!) so you need to put an rcp in front of that.
RE: offtopic: Path issues
Because sendRedirect is fundamentally completely different to the RequestDispatcher? It sends a 302 response back to the client and the client browser re-requests the new URL. RequestDispatcher only performs internal includes and forwards, so the client never knows it was used. If you need fo forward to another URL, you can always use a full URL. Not much point arguing over it though, the spec team did at length and IMHO the good guys lost ;) -mike -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Manne Fagerlind Sent: Saturday, March 17, 2001 12:55 AM To: Orion-Interest Subject: RE: offtopic: Path issues I don't see this as a spec bug, I think it's quite deliberate. Sometimes you need to redirect to sth outside the web app. What'd be the point of having sendRedirect() duplicate the functionality of the RequestDispatcher? /Manne NOTE: All JSP commands are relative to the web app root EXCEPT response.sendRedirect() which is relative to the host (stupid spec bug!) so you need to put an rcp in front of that.
RE: offtopic: Path issues
Mr Farquhar, You must always use rcp (or %= request.getContextPath() %) in front of every path to make your web app fully portable. It may be tedious but there's no other way around it besides making every path relative (which is sometimes not possible with include files etc) In stylesheets and JS files, use relative paths, this is the only way I can see to do this effectively. It shouldn't be too much of a problem though. %@ include % and jsp:include are always relative to the web app root. NOTE: All JSP commands are relative to the web app root EXCEPT response.sendRedirect() which is relative to the host (stupid spec bug!) so you need to put an rcp in front of that. -mike -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of SCOTT FARQUHAR Sent: Friday, March 16, 2001 10:17 AM To: Orion-Interest Subject: offtopic: Path issues When I have multiple web applications running on the one server - I'm having problems referencing files in other directories. eg - I can't use "/images/anImage.gif" because that references the document root. I can use "%= request.getContextPath() %/images/anImage.gif" ,but that gets tedious. Is there a better way to do it? The other problem I have is referencing images from stylesheets and javascript files. Because they don't go through the JSP processor, I can't use request.getContextPath() . Without mapping .css and .js to the jsp servlet - is there a way around this? Also - with include files - are they always rooted from the web context ie @ include file="/includes/pageheader.jsp" % -- does this map to http://myserver.com/mywebapp/includes/pageheader.jsp ? Does the same go for jsp:include page="/includes/pageheader.jsp" / ? Thanks in advance for any help. Scott
RE: offtopic: Path issues
I havent found a better way than the tedious %=request.getContextPath()% In your web.xml, you can specify other file extenstions that can get compiled into a servlet eg !-- lets the servlet container know that anything with a .css extension is to be compiled into a jsp -- servlet-mapping servlet-namejsp/servlet-name url-pattern/*.css/url-pattern /servlet-mapping !-- lets the servlet container know that anything with a .js extension is to be compiled into a jsp -- servlet-mapping servlet-namejsp/servlet-name url-pattern/*.js/url-pattern /servlet-mapping -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of SCOTT FARQUHAR Sent: Friday, 16 March 2001 9:17 AM To: Orion-Interest Subject: offtopic: Path issues When I have multiple web applications running on the one server - I'm having problems referencing files in other directories. eg - I can't use "/images/anImage.gif" because that references the document root. I can use "%= request.getContextPath() %/images/anImage.gif" ,but that gets tedious. Is there a better way to do it? The other problem I have is referencing images from stylesheets and javascript files. Because they don't go through the JSP processor, I can't use request.getContextPath() . Without mapping .css and .js to the jsp servlet - is there a way around this? Also - with include files - are they always rooted from the web context ie @ include file="/includes/pageheader.jsp" % -- does this map to http://myserver.com/mywebapp/includes/pageheader.jsp ? Does the same go for jsp:include page="/includes/pageheader.jsp" / ? Thanks in advance for any help. Scott