tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chris Haynes" <ch...@harvington.org.uk>
Subject Re: Path Problem- URGENT
Date Tue, 27 Feb 2001 23:30:30 GMT
Amitabh,

I don't quite understand what you are trying to do when you say you
want to 'access' your .jsp file from within
your servlet.

If you are trying to get the servlet to tell tomcat what file to send
to the user you can use

getServletContext().getRequestDispatcher("error.jsp").forward(request,
response);

That will be the last thing the servlet does during that call - and
tomcat will use the compiled version of error.jsp to generate the
response to the user.

You can feed data from the servlet to the .JSP by using
request.setAttribute("xxx") in the servlet and then
<%=request.getAttribute("xxx")%> in the JSP


Alternatively you could make the last method  insert(,) to embed the
output of the .jsp among other output from the servlet..


If, on the other hand, you are trying (for some strange reason) to
read the actual error.jsp file itself into the servlet as a string or
whatever, you can use

getServletContext.getRealPath("error.jsp")

to return the full path name to that file - but I can't think why you
would want to do this.

Chris



----- Original Message -----
From: "amitabh dubey" <amitabhd@rocketmail.com>
To: <tomcat-user@jakarta.apache.org>
Sent: Tuesday, February 27, 2001 10:55 PM
Subject: Path Problem- URGENT


> Hello,
>    I am using Tomcat 3.1 on a win2k platform. I am
> able to access my servlets from a browser, but am
> unable to access my html and jsp pages from within my
> servlets themselves. If i choose a path like
> "index.htm", the complete path assumed is
> c:\jakarta-tomcat\bin\index.htm. If i change it to
> /index.htm, the assumed path is c:index.htm. If i
> choose the path as ./index.htm, the path assumed is
> c:\jakarta-tomcat\bin\./index.htm.
>
> Please can someone tell me hoow do i access a file say
> "error.jsp" from withing my servlets that are
> installed in
> c:\jakarta-tomcat\webapps\LDS\WEB-INF\classes
>
>
> Thank you
> Amitabh
>
>
> __________________________________________________
> Do You Yahoo!?
> Get email at your own domain with Yahoo! Mail.
> http://personal.mail.yahoo.com/
>
> --------------------------------------------------------------------
-
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, email: tomcat-user-help@jakarta.apache.org
>
>


Mime
View raw message