?
Solved

Problem deploying WAR file

Posted on 2003-03-05
5
Medium Priority
?
476 Views
Last Modified: 2010-04-01
Problem deploying WAR file  Posted: Mar 5, 2003 11:36 PM   Reply  
 
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();
}
}  
0
Comment
Question by:KABOOM
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 

Expert Comment

by:richiegr
ID: 8078255
Hi

If you use Tomcat > 4 then you don't need to make any change to the server.xml file you have just (better) to stop tomcat then only copy you war file under /webapps dir

If you war file if correct Tomcat extract the file under webapps dir so if you war filename is test.war you'll have:
this dir :
C:\Tomcat 4.1\webapps\test

To access your servlet or jsp page use the url:
http://localhost:8080/test

if you have configured a default page like index.jsp or default.html you should see it

Bye
0
 
LVL 3

Expert Comment

by:NetWize
ID: 8079021
and for your servlet to work you need a

<servlet-mapping>
  <servlet-name>Hello World Servlet</servlet-name>
  <url-pattern>/HelloWorldServlet</url-pattern>
</servlet-mapping>
0
 
LVL 28

Expert Comment

by:rrz
ID: 8080496
I agree with NetWize.
Also look at the DTD for a web.xml. You don't have order correct.
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 8081571
>> <Context path="/test" docBase="webapps/test" crossContext="false" debug="0" reloadable="true"/>

this is wrong, should be docBase="test"

also, you need the mapping as NetWize suggested in your web.xml

it is recommended that you always have an html file in your war. and try to access the html file first, that ensures you app is installed without problem, then try servlets.
0
 
LVL 1

Accepted Solution

by:
myuen earned 200 total points
ID: 8085325
I think NetWize is right but I totally had the same problem and i'll tell you what did the trick for me:

In your web.xml:

REPLACE:
<servlet-name>Hello World Servlet</servlet-name>

WITH:
** NOTICE that there are no spaces in between.  I'm not quite sure why this made a difference for me b/c it's just a name - but it does.
<servlet-name>HelloWorldServlet</servlet-name>

Try it!
Let me know how it turns out.
Later dude.
0

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article lists the top 5 free OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their exchange server is no longer available or some other critical issue with exchange server or impor…
Check out the latest tech news, community articles, and expert highlights in August's newsletter.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question