 |
 |
jakarta-tomcat
|
 |
|
 |
|
Forum Regular
Join Date: Jul 2000
Location: Jersey City, NJ 07304
Status:
Offline
|
|
Let's talk tomcat. I've got it running. And I've figured out how to set my CLASSPATH using csh.cshrc. And I have my servlets running there now. (mm.mysql2.01 also works so I'm talking with a remote MySQL server)
But I'd like to create alias's. i.e. I would like http://localhost:8080/hello to go directly to: http://localhost:8080/servlet/HelloWorld
I've tried using a <context> in the server.xml file. But my browser tries to download the class file instead of executing it.
How do I do this?
|
|
|
| |
|
|
|
 |
|
 |
|
Forum Regular
Join Date: Jul 2000
Location: Jersey City, NJ 07304
Status:
Offline
|
|
OK, to answer my own question. Here's how to create an alias (or servlet-mapping) i.e. how to map a URI to a specific servlet in Tomcat:
open the file: [tomcatfolder]/webapps/ROOT/WEB-INF/web.xml
for each mapping use the xml:
<servlet-mapping>
<servlet-name>YourServlet</servlet-name>
<url-pattern>/yourURI</url-pattern>
</servlet-mapping>
inside the <web-app> tags
restart Tomcat.
I found this site VERY helpful and I really appreciate that this Perl programmer created an web page to search the Tomcat discussion list archives: http://www.metronet.com/~wjm/tomcat/
- miles
|
|
|
| |
|
|
|
 |
|
 |
|
jhh
|
|
I think you should add a Context tag in conf/server.xml
something like:
<Context docBase="mystuff" path="/mystuff"
reloadable="false" trusted="true">
</Context>
then do your servlet-mapping in webapps/mystuff/WEB-INF/web.xml
jhh
|
|
|
| |
|
|
|
 |
|
 |
|
Forum Regular
Join Date: Jul 2000
Location: Jersey City, NJ 07304
Status:
Offline
|
|
Maybe you're right, since my solution doesn't quite work like I need it too. with the current set-up, a link like www.mysite.com/hello goes to my HelloWorld servlet, as mapped. However, when I try to pass a param like this: www.mysite.com/hello/param, then it doesn't work, and thinks its a different URI. So I tried, in web.xml, a mapping like this:
<servlet-mapping>
<servlet-name>HelloWorld</servlet-name>
<url-pattern>/hello/*</url-pattern>
</servlet-mapping>
but it doesn't work.
the mappings in server.xml seem to point to real directories in Tomcat's folder. But how to make one that points to the servlet execution engine, like I assume /servlet points to this engine.
- miles
|
|
|
| |
|
|
|
 |
|
 |
|
jhh
|
|
"I feel your pain"
Things are not working too well for me either. There seems to be a huge lack of understandable documentation...
You could try mapping to "/" in your web.xml
<web-app>
<servlet>
<servlet-name>HelloWorld<servlet-name>
<servlet-class>where.ever.HelloWorld<servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HelloWorld</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
In my case something in the config is causing an infinite redirect loop which, while fun to watch, is not the right behavior.
I've had to modify bin/catalina.sh to add classes to the classpath and conf/server.xml to add Contexts and then the associated webapp web.xml for servlet definition.
One thing that confuses me is the WEB-INF directory - why is it there?
jhh
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |