You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Mark R. Diggory" <md...@latte.harvard.edu> on 2002/08/29 00:17:12 UTC

How do I get hold of a resource relative to a JSP Page?

I'm trying to get a file in the filesystem relative to the location of a 
JSP Page. At first Blush the following would seem appropriate:

<%
String jsp_location = application.getRealPath(request.getServletPath());

String relative = jsp_location.substring(0,jsp_location.lastIndexOf("/"));

... get the resource using this path ...

%>

however, when one uses a servlet mapping on a JSP Page like below.

  <servlet>
    <servlet-name>JSPTestMap</servlet-name>
    <jsp-file>/Jaxp/JSPTransformExample.jsp</jsp-file>
  </servlet>
  <servlet-mapping>
    <servlet-name>JSPTestMap</servlet-name>
    <url-pattern>/Jaxp/MapExample.jsp</url-pattern>
  </servlet-mapping>

request.getServletPath() returns

<url-pattern>/Jaxp/MapExample.jsp</url-pattern>

and not

<jsp-file>/Jaxp/JSPTransformExample.jsp</jsp-file>

is there any way I can get hold of the original real location of the JSP 
Page I'm working in and have it also work with servlet-mappings?

-Mark Diggory






--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: session tracking using URL rewriting & META=refresh

Posted by Srinadh Karumuri <sk...@bbn.com>.
It looks like no one had to deal with this earlier. I made a work around, 
not fancy but works.
I used:
<META HTTP-EQUIV=Refresh
CONTENT="600;
URL=../jsp/UserMessage.jsp?jsessionid=To1071mC22961575233267228At&msgid=1001&grace=120;">

and in this page for <form> etc., I used:
<form action=<%= "/jsp/newPage;jsessionid=" + 
request.getParameter("jsessionid")%>>

-Sri

At 10:27 AM 8/29/2002, Srinadh Karumuri wrote:
>Hi,
>
>I know there are two ways of session tracking in Tomcat 3.
>1. Cookies based: This is out of question as our customers do not want this.
>2. URL rewriting: We rewrite URLs using encodeURL(...) and worked fine for 
>more than a year.
>
>The problem started once we introduced the META-Refresh to forward user's 
>screen after time out when Javascript is OFF. The copy of the HTML source 
>from browser is as below:
>
><META HTTP-EQUIV=Refresh
>CONTENT="600;
>URL=../jsp/UserMessage.jsp;jsessionid=To1071mC22961575233267228At?msgid=1001&grace=120;">
>
>Since semi-colon marks the  end of URL, browser was not forwarding the 
>jsessionid. If I copy the URL into browser manually, it works fine.
>
>Q1. Is there a third way of session tracking? I remember reading somewhere 
>about keeping an hidden <input> field with name="jsessionid" in the page.
>
>Any help on this?
>
>Q2. I guess tomcat doesn't support any other character in the place of 
>semi-colon. Is there any way to escape this character in the META value?
>
>Note: We need to use Javascript OFF per customer's requirements.
>
>Thanks,
>Sri
>
>
>jsp/etrUserMessage.jsp;jsessionid=To1075mC2510161898001374At?msgid=1001&grac 
>e=120
>
>
>--
>To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
>For additional commands, e-mail: <ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


session tracking using URL rewriting & META=refresh

Posted by Srinadh Karumuri <sk...@bbn.com>.
Hi,

I know there are two ways of session tracking in Tomcat 3.
1. Cookies based: This is out of question as our customers do not want this.
2. URL rewriting: We rewrite URLs using encodeURL(...) and worked fine for 
more than a year.

The problem started once we introduced the META-Refresh to forward user's 
screen after time out when Javascript is OFF. The copy of the HTML source 
from browser is as below:

<META HTTP-EQUIV=Refresh
CONTENT="600;
URL=../jsp/UserMessage.jsp;jsessionid=To1071mC22961575233267228At?msgid=1001&grace=120;">

Since semi-colon marks the  end of URL, browser was not forwarding the 
jsessionid. If I copy the URL into browser manually, it works fine.

Q1. Is there a third way of session tracking? I remember reading somewhere 
about keeping an hidden <input> field with name="jsessionid" in the page.

Any help on this?

Q2. I guess tomcat doesn't support any other character in the place of 
semi-colon. Is there any way to escape this character in the META value?

Note: We need to use Javascript OFF per customer's requirements.

Thanks,
Sri


jsp/etrUserMessage.jsp;jsessionid=To1075mC2510161898001374At?msgid=1001&grac 
e=120


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Is this a Bug in request.getServletPath() ?

Posted by "Mark R. Diggory" <md...@latte.harvard.edu>.
I'm trying to get a file in the filesystem relative to the location of a 
JSP Page. At first Blush the following would seem appropriate:

<%
String jsp_location = application.getRealPath(request.getServletPath());

String relative = jsp_location.substring(0,jsp_location.lastIndexOf("/"));

... get the resource using this path ...

%>

however, when one uses a servlet mapping on a JSP Page like below.

 <servlet>
   <servlet-name>JSPTestMap</servlet-name>
   <jsp-file>/Jaxp/JSPTransformExample.jsp</jsp-file>
 </servlet>
 <servlet-mapping>
   <servlet-name>JSPTestMap</servlet-name>
   <url-pattern>/Jaxp/MapExample.jsp</url-pattern>
 </servlet-mapping>

request.getServletPath() returns

<url-pattern>/Jaxp/MapExample.jsp</url-pattern>

and not

<jsp-file>/Jaxp/JSPTransformExample.jsp</jsp-file>

is there any way I can get hold of the original real location of the JSP 
Page I'm working in and have it also work with servlet-mappings?

-Mark Diggory



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>