tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Xeth Waxman <xwax...@gmail.com>
Subject Re: Traversing up a directory using RequestDispatcher
Date Fri, 17 Sep 2004 15:44:51 GMT
I am sorry, I don't think I am explaining well.  My english
comprehension is still new, so I am doing a poor job.  I have jsp page
login.jsp in <CATALINA_HOME>/webapps/ChargeCard (let's call it
<APP_HOME>).  I have moved my servlets from
<CATALINA_HOME>/webapps/ROOT/WEB-INF/classes to
<APP_HOME>/WEB-INF/classes.  So my question is twofold:

1) from my jsp, how do I invoke the servlet in it's new location? 
Prior I was using:
<form method="POST" name=mainform
action="servlet/com.gcc.creditcard/CCLogin"> but that no longer works,
and it doesn't work without the servlet prefix either.

2) Once I am sucessfully able to invoke CCLogin, how do I dispatch to
my second jsp (keeping my session variables)?  I think Yoav answered
this for me though - now that the servlets are in same context, I
should be able to use
RequestDispatcher rd = 
			getServletContext().getRequestDispatcher("/CCEntry.jsp");

But I can't test this theory until first issue is resolved.  I thank
everyone (especially Yoav, who is my new java superhero) for your
patience with me!  Tomcat user list is the best!

--Xeth


On Fri, 17 Sep 2004 11:26:50 -0400, Shapira, Yoav <yoav.shapira@mpi.com> wrote:
> 
> Hi,
> Declare a <servlet> and <servlet-mapping> element for every one of your
> servlets in web.xml.  Use the url-pattern from the servlet-mapping as
> the argument for getRequestDispatcher().
> 
> Yoav Shapira
> Millennium Research Informatics
> 
> 
> 
> 
> >-----Original Message-----
> >From: Xeth Waxman [mailto:xwaxman@gmail.com]
> >Sent: Friday, September 17, 2004 11:25 AM
> >To: Shapira, Yoav
> >Cc: Tomcat Users List
> >Subject: Re: Traversing up a directory using RequestDispatcher
> >
> >OK, so apparently I am doing a cross context request dispatcher call,
> >which is bad.  So I shouldn't do that.  Assuming my app is under
> >c:\jakarta\webapps\ChargeCard (context is /ChargeCard), that means my
> >servlets should be under
> >c:\jakarta\webapps\ChargeCard\WEB-INF\classes, correct?  If that is
> >the case, how do I get my pages to invoke my servlets?  To date I have
> >been putting my servlets in c:\jakarta\webapps\ROOT\WEB-INF\classes,
> >and invoking them with /servlet/com.gcc.creditcard.DoLogin.  Now that
> >my classes are under /ChargeCard, invoking them with
> >/servlet/com.gcc.creditcard.DoLogin says that they're not found, and
> >likewise with just com.gcc.creditcard/DoLogin.  I'm sure their's a
> >very simple answer found somewhere I just don't know where to look, so
> >if you feel like making me work to get the answer feel free to just
> >point out the resource I should be viewing (I can't find anything in
> >the tomcat docs).
> >
> >Thanks!
> >
> >--Xeth
> >
> >
> >On Fri, 17 Sep 2004 08:17:07 -0400, Shapira, Yoav
> <yoav.shapira@mpi.com>
> >wrote:
> >>
> >> Hi,
> >> First of all, Xeth is the best name I've seen in a long time -- cool!
> >>
> >>
> >>
> >> >I have a bizarre issue.  Using Tomcat 5.0.12, I have an application
> in
> >> >the directory C:\jakarta-tomcat-5.0.12\webapps called ChargeCard.
> >> >After loggin in, I am trying to forward a request to jsp page in
> that
> >> >directory.  However, RequestDispatcher apparently uses the directory
> >> >C:\jakarta-tomcat-5.0.12\webapps\ROOT as the Document root, so I
> need
> >> >to go up a directory in my forward request (something like url =
> >> >"../ChargeCard/index.jsp";)  However, RequestDispatcher requires a /
> >> >to start off the url, so I can't use the ../ start to go up a
> >> >directory.  Does anyone have an idea how I would do this?  I tried
> url
> >> >= "/../ChargeCard/index.jsp";, but that results in a
> >> >NullPointerException being thrown.  All help is appreciated!
> >>
> >> The RequestDispatcher's behavior is constrained by the Servlet
> >> Specification.  Its JavaDoc has an explanation on how it resolves
> >> relative links: the leading slash for the getRequestDispatcher call
> is
> >> not really absolute, it's relative to the webapp's docBase.
> >>
> >> There's no reason Tomcat would use ROOT as the docBase, unless you're
> >> actually in the root webapp.  What is the docBase for your webapp?
> >> (Hint: it's not c:\jakarta-tomcat-5.0.12\webapps, it's a subdirectory
> >> under it, unless you've explicitly defined a Context with the webapp
> >> docBase) (in which case, if you kept the default Host appBase, you
> have
> >> a bad configuration).
> >>
> >> Yoav
> >>
> >> This e-mail, including any attachments, is a confidential business
> >communication, and may contain information that is confidential,
> >proprietary and/or privileged.  This e-mail is intended only for the
> >individual(s) to whom it is addressed, and may not be saved, copied,
> >printed, disclosed or used by anyone else.  If you are not the(an)
> intended
> >recipient, please immediately delete this e-mail from your computer
> system
> >and notify the sender.  Thank you.
> >>
> >>
> >
> >
> >
> >--
> >Xeth Waxman
> >xwaxman@gmail.com
> 
> 
> 
> 
> This e-mail, including any attachments, is a confidential business communication, and
may contain information that is confidential, proprietary and/or privileged.  This e-mail
is intended only for the individual(s) to whom it is addressed, and may not be saved, copied,
printed, disclosed or used by anyone else.  If you are not the(an) intended recipient, please
immediately delete this e-mail from your computer system and notify the sender.  Thank you.
> 
> 



-- 
Xeth Waxman
xwaxman@gmail.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