tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark B. Indictor" <...@fiddler.com>
Subject RE: REPOST: Please HELP!: URL Mapping Problems in servlet
Date Wed, 27 Feb 2002 18:16:34 GMT
If the URL is: http://hostname/context/servlet/xxx

Then:

req.getPathInfo() returns:	/xxx
req.getRequestURI() returns:	/context/servlet/xxx
req.getServletPath() returns:	/servlet

How do I get just: /context/servlet

OR

How do I get Apache or Tomcat to respond to: http://hostname/servlet/xxx?

Thanks

    - mbi
======================================================
Mark Indictor -- Site2 Corporation
mbi@site2.com
<http://www.site2.com>
Phone:(310)451-3472 FAX:(240)220-6341
http://keyserver.pgp.com/pks/lookup?op=get&search=0x8959F966
====================================================== 




-----Original Message-----
From: Cox, Charlie [mailto:ccox@cincom.com] 
Sent: Wednesday, February 27, 2002 9:46 AM
To: 'Tomcat Users List'
Subject: RE: REPOST: Please HELP!: URL Mapping Problems in servlet


try req.getPathInfo() in place of getServletPath()

you can use getRequestURL() which will provide the requested URL that you
are trying to rebuild.

Charlie

> -----Original Message-----
> From: Mark B. Indictor [mailto:mbi@fiddler.com]
> Sent: Wednesday, February 27, 2002 12:24 PM
> To: 'Tomcat Users List'
> Subject: REPOST: Please HELP!: URL Mapping Problems in servlet
> 
> 
> OK -- I'm having a related problem:
> 
> I can hit my servlet with the following httpd.conf and
> web.xml file setup
> with these two URLs:
> 
> http://hostname:8080/s2/sb/
> 
> And
> 
> http://hostname/SiteBlocks/sb/
> 
> 
> From within the servlet, I am trying to reconstruct the URL.
> I am using the
> following code:
> 
> ...
> private String buildURL( HttpServletRequest req ) {
> 	// Build a new absolute URL
> 	StringBuffer url = new StringBuffer();
> 	url.append( req.getScheme() );	// http
> 	url.append( "://" ); 			// http://
> 	url.append( req.getServerName() ); 	// http://hostname
> 	url.append( ":" );			// http://hostname:
> 	url.append( req.getServerPort() );	// http://hostname:80
> 	url.append( req.getServletPath() );	//
> http://hostname:80/SiteBlocks/sb
> 	return url.toString();
> }
> ...
> 
> Unfortunately, the URL this produces is either:
> 
> http://hostname:8080/sb or http://hostname/sb,
> 
> 	and not
> 
> http://hostname:8080/s2/sb or http://hostname/SiteBlocks/sb
> 
> as expected.
> 
> Am I doing something wrong? If so, how can I get the desired result?
> 
> 
> Thanks for any assistance!
> 
> Here's an excerpt from my httpd.conf file:
> 
> ...
> <IfModule od_webapp.c>
> 	WebAppConnection warpconnection warp localhost:8008
> 	WebAppDeploy examples warpConnection /examples/
> 	WebAppDeploy SiteBlocks warpConnection /SiteBlocks/ </IfModule>
> ...
> 
> 
> Here's my entire web.xml file:
> 
> <?xml version="1.0" encoding="ISO-8859-1"?>
> 
> <!DOCTYPE web-app
>     PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
>     "http://java.sun.com/dtd/web-app_2_3.dtd">
> 
> <web-app>
>     <servlet>
>         <servlet-name>
>             SiteBlocks
>         </servlet-name>
>         <servlet-class>
>             S2Server
>         </servlet-class>
>         <init-param>
>             <param-name>resource</param-name>
>  
> <param-value>/usr/local/jakarta-tomcat-4.0.2/webapps/SiteBlock
> s/WEB-INF/Site
> BlocksServer.properties</param-value>
>         </init-param>
>     </servlet>
> 
>     <servlet-mapping>
>         <servlet-name>
>             SiteBlocks
>         </servlet-name>
>         <url-pattern>
>             /sb
>         </url-pattern>
>     </servlet-mapping>
> </web-app>
> 
>     - Mark ======================================================
> Mark Indictor -- V.P. Engineering
> mbi@site2.com
> <http://www.site2.com>
> Phone:(310)451-3472 FAX:(240)220-6341
> http://keyserver.pgp.com/pks/lookup?op=get&search=0x8959F966
> ====================================================== 
> 
> 
> -----Original Message-----
> From: Dave Ferguson [mailto:dferguson@touchnet.com]
> Sent: Tuesday, February 26, 2002 12:11 PM
> To: Tomcat Users List
> Subject: Re: servlet-mapping problem
> 
> 
> This is basic stuff.  It should work.  What URL are you using
> to invoke the
> servlet?  With no mapping the URL would be 
> http://server/servlet/warservlet.
> If your mapping is
> 
>   <url-pattern>/blah</url-pattern>
> 
> then the URL would be http://server/blah.  Restart Tomcat to
> be sure your
> changes take effect.
> 
> - df
> 
> 

--
To unsubscribe:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands: <mailto:tomcat-user-help@jakarta.apache.org>
Troubles with the list: <mailto:tomcat-user-owner@jakarta.apache.org>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message