The Artima Developer Community
Sponsored Link

Java Answers Forum
Problem deploying WAR file

1 reply on 1 page. Most recent reply: Mar 8, 2003 3:33 PM by Charles Bell

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Mike Yuen

Posts: 3
Nickname: kaboom
Registered: Nov, 2002

Problem deploying WAR file Posted: Mar 5, 2003 8:36 PM
Reply to this message Reply
Advertisement
Hey guys, i'm really new to this servlet stuff and need a bit of help. I wrote a simple helloworld servlet below but it won't display. Below is a detailed account of what is in each of my files and the location of each file.
NOTE:I then followed Tomcat installation tutorial at http://www.massless.org/Default.asp?article=1 pretty close!

Now, my TOMCAT root is at:
C:\Tomcat 4.1\

I created the war file (test.war) no problem and put it in the
{TOMCAT root}\webapps

Tried to access my page at: http://localhost:8080/test/HelloWorldServlet
and I got the following error:

----------------------------------------------------------------
TOMCAT ERROR
----------------------------------------------------------------
HTTP Status 404 - /test/HelloWorldServlet
type Status report
message /test/HelloWorldServlet
description The requested resource (/test/HelloWorldServlet) is not available.

----------------------------------------------------------------
SE RVER.XML
----------------------------------------------------------------
Then I added the following entry into server.xml ABOVE the other context path item in the file:
<Context path="/test" docBase="webapps/test" crossContext="false" debug="0" reloadable="true"/>

------------------------------------------------------- ---------
WEB.XML
-------------------------------------------------------------- --
I then added the following entry into my web.xml file and stuck it in
C:\Tomcat 4.1\webapps\test\WEB-INF:
<web-app>
<display-name>Hello World!</display-name>
<session-timeout>30</session-timeout>
& lt;servlet>
<servlet-name>Hello World Servlet</servlet-name>
<servlet-class>HelloWorldServlet</servlet -class>
<load-on-startup>1</load-on-startup>
<init-param>
& lt;param-name>name</param-name>
<param-value>value</param-valu e>
</init-param>
</servlet>
</web-app>

------------------- ---------------------------------------------
HELLOWORLDSERVET.JAVA
------------ ----------------------------------------------------
//Import Servlet libraries
import javax.servlet.*;
import javax.servlet.http.*;
//Import Java libraries
import java.io.*;
public class HelloWorldServlet extends HttpServlet
{
public void doGet (HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
{
res.setContentType("text/html");
PrintWriter out = res.getWriter();
out.println("<html>");
out.println("<body>");
out.println("<h1& gt;Hello World!</h1>");
out.println("</body>");
out.println("</html>") ;
out.close();
}
}


Charles Bell

Posts: 519
Nickname: charles
Registered: Feb, 2002

Re: Problem deploying WAR file Posted: Mar 8, 2003 3:33 PM
Reply to this message Reply
Try the url:
http://localhost:8080/HelloWorldServlet/

Flat View: This topic has 1 reply on 1 page
Topic: Please help with school project Previous Topic   Next Topic Topic: COOL Java Menu

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use