• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt on deploying servlet

 
Ashok Pradhan
Ranch Hand
Posts: 180
Eclipse IDE Firefox Browser Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have cleared SCJP 6 on 15th Oct.
Now I am preparing for SCWCD.In HF Servlet the example Ch1Servlet I found some difficulty.please help me..

>>I create the Ch1Servlet.java and compile it and have the Ch1Servlet.class file.

>>create the web.xml file and the contents are:-



>>and create the directory structure
ch1
|
|index.html
|WEB-INF
 |
 |web.xml
 |classes
  |
  |Ch1Servlet.class

>>start the tomcat

>>copy ch1 directory and paste inside C:\Program Files\Tomcat 5.5\webapps

>>open firefox
http://localhost:10080/ch1 [press enter]
then it shows me the index page

but when I put
http://localhost:10080/ch1/Serv1

the it shows :

HTTP Status 404 - type Status report message description The requested resource () is not available. Apache Tomcat/5.5.27
[ October 19, 2008: Message edited by: Ashok Pradhan ]
 
Mr.Rakesh Kumar
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
------------------
Hi Ashok,



-------------------

You could see your errors yourself, You have not closed the <sevlet-mapping> tag and also forgot to put the opening <servlet-name> tag there,

Corrected xml should to be:

<web-app>

<servlet>
<servlet-name> ... </servlet-name>
<servlet-class>Ch1Servlet</servlet-class>
</servlet>

<servlet-mapping>

<servlet-name> ... </servlet-name>
<url-pattern> ??? </url-pattern>

</servlet-mapping>

</web-app>

-------------------------

... means the servlet name anything that you want to give there, but same at both places,

??? means the path name that you would put to call the servlet, any thing that you want.

Hoping this might help you to get your output.

Thanks.

Rakesh.
SCJP-86%
 
Mr.Rakesh Kumar
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You gets your html page because that is a static page, it does not require any servlet help, and hence it is shown to you, but when it comes to the dynamic page that you request by sending the request .../Serv1, it shows you the error.
Not only that you can also see the log files of your tomcat installation ..../Program Files/Tomcat5.X/logs/, there will be error showing with this webapps name.

"<servlet-mapping> has no end tag" and the "<servlet-name>" has no opening tag.

Because the XML file is read at the start of the Tomcat, please take a note that the XML file is a sensitive document.

Thanks.
Rakesh
SCJP-86%
 
Deepak Jain
Ranch Hand
Posts: 637
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The best thing to do next time would be
a) Go to Tomcat C:\Program Files\Apache Software Foundation\Tomcat 5.0\logs
And look for localhost_*.txt
This log file would give you details about your mistakes when deploying your webapp.
 
Ashok Pradhan
Ranch Hand
Posts: 180
Eclipse IDE Firefox Browser Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks,Now I correct it and it works ..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic