Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 27th, 2003, 01:59 PM
changhai changhai is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Posts: 49 changhai User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 57 m 57 sec
Reputation Power: 7
Question Help, servlet can be invoked by ANY name ?!

I wrote a simple servlet that does nothing but outputs "hello world" to the browser. I used j2ee server and deploytool. I have set the context root to be "helloworld" in the deploytool. After deployment, I can access the servlet at

http://localhost:8000/helloworld/*

where "*" stands for ANY name! Is this supposed to be the behavior? I can access the servlet without using a more specific name related to the servlet class name?

Thanks for help.

Reply With Quote
  #2  
Old March 27th, 2003, 04:16 PM
Nemi Nemi is offline
Clueless llama
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Feb 2001
Location: Lincoln, NE. USA
Posts: 2,353 Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 2 Days 12 h 35 m 19 sec
Reputation Power: 111
Your web.xml must be set that way. Post it here. It is located in teh WEB-INF folder.

Reply With Quote
  #3  
Old March 28th, 2003, 10:06 AM
changhai changhai is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Posts: 49 changhai User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 57 m 57 sec
Reputation Power: 7
Quote:
Originally posted by Nemi
Your web.xml must be set that way. Post it here. It is located in teh WEB-INF folder.


It's here:

<?xml version="1.0" encoding="UTF-8"?>

<!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>
<display-name>HelloWorldWarDispName</display-name>
<servlet>
<servlet-name>HelloWorldServletCompName</servlet-name>
<display-name>HelloWorldServletCompName</display-name>
<servlet-class>HelloWorldServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HelloWorldServletCompName</servlet-name>
<url-pattern>/HelloWorldAlias</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>HelloWorldServletCompName</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>30</session-timeout>
</session-config>
</web-app>

Reply With Quote
  #4  
Old March 28th, 2003, 10:47 AM
Nemi Nemi is offline
Clueless llama
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Feb 2001
Location: Lincoln, NE. USA
Posts: 2,353 Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 2 Days 12 h 35 m 19 sec
Reputation Power: 111
This is your problem:
Code:
<servlet-mapping>
<servlet-name>HelloWorldServletCompName</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>

If you remove that section you will only be able to access that servet by typing in:


See how that servlet-mapping works? Basically, you said anything that comes in to this host will be returned by this servlet.

Reply With Quote
  #5  
Old March 28th, 2003, 01:16 PM
changhai changhai is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Posts: 49 changhai User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 57 m 57 sec
Reputation Power: 7
Unhappy

I tried this, but the servlet is still accessible by any name. I tried to restart j2ee after the change, that also didn't work because each time j2ee is started, it re-generates that old web.xml file.

Reply With Quote
  #6  
Old March 28th, 2003, 01:51 PM
Nemi Nemi is offline
Clueless llama
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Feb 2001
Location: Lincoln, NE. USA
Posts: 2,353 Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 2 Days 12 h 35 m 19 sec
Reputation Power: 111
Regenerates the web.xml? How? Do you have a deployed war file it is extracting each time it starts?

Reply With Quote
  #7  
Old March 28th, 2003, 02:18 PM
changhai changhai is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Posts: 49 changhai User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 57 m 57 sec
Reputation Power: 7
Unhappy

I do have a war file named "original.war" in the context root directory, when the j2ee server is shutdown, that's the ONLY file left in the directory tree, I still have META-INF, WEB-INF, and WEB-INF/classes directories, but they are ALL empty. When I start j2ee server, those directories are populated (web.xml, class file, etc, they will all disappear again if I shutdown the server).

Maybe I forgot important option at the deployment?

Reply With Quote
  #8  
Old March 28th, 2003, 06:33 PM
Nemi Nemi is offline
Clueless llama
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Feb 2001
Location: Lincoln, NE. USA
Posts: 2,353 Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 2 Days 12 h 35 m 19 sec
Reputation Power: 111
You should be able to do one of two things
1) You can change the web.xml in whatever you orginally made it in and redeploy
or
2) You can extract the war file into the directories that the files are normally in and delete the war file. A war file is simply a zip file with another extension, so you can unzip it with any zip utility.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > Help, servlet can be invoked by ANY name ?!


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT