?
Solved

deploying WARs

Posted on 2003-03-02
3
Medium Priority
?
513 Views
Last Modified: 2010-04-20
hi - i am starting SCWCD study and am having trouble deploying servlets. Using Tomcat 4.1.18 on w2k pro under jdk1.4.1

ide is forte studio 4 U1 and jdev 9 (same problem when using either)

i created a really trivial servlet and a web.xml then deployed the WAR (as webapp1.war) to the webapps folder.

this is the web.xml
<?xml version = '1.0' encoding = 'windows-1252'?>
<!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>
  <description>Empty web.xml file for Web Application</description>
  <servlet>
    <servlet-name>Servlet1</servlet-name>
    <servlet-class>Servlet1</servlet-class>
  </servlet>
  <session-config>
    <session-timeout>30</session-timeout>
  </session-config>
  <mime-mapping>
    <extension>html</extension>
    <mime-type>text/html</mime-type>
  </mime-mapping>
  <mime-mapping>
    <extension>txt</extension>
    <mime-type>text/plain</mime-type>
  </mime-mapping>
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>index.html</welcome-file>
  </welcome-file-list>
</web-app>

this is servlet1
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.PrintWriter;
import java.io.IOException;

public class Servlet1 extends HttpServlet
{
     private static final String CONTENT_TYPE = "text/html; charset=windows-1252";

     public void init(ServletConfig config) throws ServletException
     {
          super.init(config);
     }

     public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
     {
          response.setContentType(CONTENT_TYPE);
          PrintWriter out = response.getWriter();
          out.println("<html>");
          out.println("<head><title>Servlet1</title></head>");
          out.println("<body>");
          out.println("<p>The servlet has received a GET. This is the reply.</p>");
          out.println("</body></html>");
          out.close();
     }
}
there is also an HTML file at the same level as the WEB-INF folder (which contains the classes folder and within that the servlet class)

i deployed this to the webapps folder as a built WAR and i can browse to the HTML file with http://localhost:8080/webapp1/testhtml.html but http://localhost:8080/webapp1/servlet/Servlet1 fails with a not found error.
if i drop this servlet class into one of the Tomcat example folders, it works, so i know the servlet class isnt corrupt - can anyone give me any advice ?

thanks




0
Comment
Question by:simonm99
[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
  • 2
3 Comments
 
LVL 3

Accepted Solution

by:
NetWize earned 400 total points
ID: 8063001
I guess you need a

<servlet-mapping>
  <servlet-name>Servlet1</servlet-name>
  <url-patter>/servlet/Servlet1</url-pattern>
</servlet-mapping>

below the <servlet>.

Another way to solve that would be to enable the Invoker-Servlet in server.xml in your tomcat /conf directory
0
 

Author Comment

by:simonm99
ID: 8068567
yes, perhaps - you see the web.xml was generated automatically so I'm learning something here. I'll try it and report, thanks
0
 

Author Comment

by:simonm99
ID: 8073477
thanks - i cant find a way to make JDev do this automatically so i'll have to add it manually for now.

i will investiage the invoker-servlet point also.
0

Featured Post

Create the perfect environment for any meeting

You might have a modern environment with all sorts of high-tech equipment, but what makes it worthwhile is how you seamlessly bring together the presentation with audio, video and lighting. The ATEN Control System provides integrated control and system automation.

Question has a verified solution.

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

A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
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…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses
Course of the Month13 days, 4 hours left to enroll

777 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