You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Ashish Kulkarni <ku...@yahoo.com> on 2002/09/17 01:37:09 UTC

basic question

Hi,
Sorry for asking a very basic question, but i need to
know the answer
Suppose i have a URL like below
http://localhost:8080/myapp/index.jsp

how can i find in servlet or jsp what is the
application name
like in the above case it is myapp, 
suppose there is other URL 
http://localhost:8080/myapp1/index.jsp
how can i get value of myapp1 (it can be any thing)in
my jsp or servlet
Ashish

__________________________________________________
Do you Yahoo!?
Yahoo! News - Today's headlines
http://news.yahoo.com

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


Re: basic question

Posted by Parthiban Sadasivam <no...@eth.net>.
You can use the HttpServletRequest method getRequestURI

HttpServletRequest::getRequestURI returns the string in between the
servername and the query string in the request url.
in your case you should get /myapp/index.jsp

----- Original Message -----
From: "Ashish Kulkarni" <ku...@yahoo.com>
To: "Tomcat Users List" <to...@jakarta.apache.org>
Sent: Tuesday, September 17, 2002 5:07 AM
Subject: basic question


> Hi,
> Sorry for asking a very basic question, but i need to
> know the answer
> Suppose i have a URL like below
> http://localhost:8080/myapp/index.jsp
>
> how can i find in servlet or jsp what is the
> application name
> like in the above case it is myapp,
> suppose there is other URL
> http://localhost:8080/myapp1/index.jsp
> how can i get value of myapp1 (it can be any thing)in
> my jsp or servlet
> Ashish
>
> __________________________________________________
> Do you Yahoo!?
> Yahoo! News - Today's headlines
> http://news.yahoo.com
>
> --
> 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>


Re: basic question

Posted by Andreas Probst <an...@gmx.net>.
Hi all!

If you have a HttpServletRequest req,

you can get 

String contextPath = req.getContextPath();

This would give you "/myapp".

My question is: How can I get to know the context path in 
init(), where I don't have a HttpServletRequest?

> have you tried using getServletContext() or
> getServletContextName()....
> 
I have the impression this works only if you have a context 
specified in server.xml.

Andreas

> Regards
> Prashanth
> 
> 
> --- Ashish Kulkarni <ku...@yahoo.com> wrote:
> > Hi,
> > Sorry for asking a very basic question, but i need
> > to
> > know the answer
> > Suppose i have a URL like below
> > http://localhost:8080/myapp/index.jsp
> > 
> > how can i find in servlet or jsp what is the
> > application name
> > like in the above case it is myapp, 
> > suppose there is other URL 
> > http://localhost:8080/myapp1/index.jsp
> > how can i get value of myapp1 (it can be any
> > thing)in
> > my jsp or servlet
> > Ashish
> > 
> > __________________________________________________
> > Do you Yahoo!?
> > Yahoo! News - Today's headlines
> > http://news.yahoo.com
> > 
> > --
> > To unsubscribe, e-mail:  
> > <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> > <ma...@jakarta.apache.org>
> > 
> 
> 
> __________________________________________________
> Do you Yahoo!?
> Yahoo! News - Today's headlines
> http://news.yahoo.com
> 
> --
> 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>


Re: basic question

Posted by Prashanth Pushpagiri <pr...@yahoo.com>.
have you tried using getServletContext() or
getServletContextName()....

Regards
Prashanth


--- Ashish Kulkarni <ku...@yahoo.com> wrote:
> Hi,
> Sorry for asking a very basic question, but i need
> to
> know the answer
> Suppose i have a URL like below
> http://localhost:8080/myapp/index.jsp
> 
> how can i find in servlet or jsp what is the
> application name
> like in the above case it is myapp, 
> suppose there is other URL 
> http://localhost:8080/myapp1/index.jsp
> how can i get value of myapp1 (it can be any
> thing)in
> my jsp or servlet
> Ashish
> 
> __________________________________________________
> Do you Yahoo!?
> Yahoo! News - Today's headlines
> http://news.yahoo.com
> 
> --
> To unsubscribe, e-mail:  
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 


__________________________________________________
Do you Yahoo!?
Yahoo! News - Today's headlines
http://news.yahoo.com

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