Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > Servlets
|
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Servlets section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 18th, 2003, 02:37 PM
Registered User
 
Join Date: Jun 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Pro JSP Servlet example

"Your First Servlet" example on pg. 64 (Pro JSP, 2nd edition) doesn't work in Tomcat. The servlet cannot be found (404 error). No mention is made of how to modify web.xml, which needs to be changed: the text says only "We will expand on our use of web.xml as it is needed below". but then it doesn't mention it again.


 
Old June 20th, 2003, 02:07 AM
Registered User
 
Join Date: Jun 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The servlet works fine. Check your web.xml file in %CATALINA_HOME%\webapps\myApplicationName\WEB-INF.

You must include the servlet descriptor:

<servlet>
   <servlet-name>MyServlet</servlet-name>
   <servlet-class>com.MyPackage.MyTest.MyServlet</servlet-class>
</servlet>

and a servlet mapping entry

<servlet-mapping>
    <servlet-name>MyServlet</servlet-name>
    <url-pattern>/MyServlet</url-pattern>
</servlet-mapping>

Then you can call the servlet with the url
http://myhost:myport/myApplicationName/MyServlet

after restarting Tomcat.

When you ask a question in a newsgroup, you should always include which version of software you are using, which platform. Also, check your logfiles for any specific error messages.
 
Old September 5th, 2003, 08:48 PM
Registered User
 
Join Date: Sep 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi.
I have configured WLS8.1 on WnXP-Prof. I am getting the same error like Marvin. I tried adding <servlet-mapping> section also as suggested by infnist, but the error persists.
Error Text:
===========
Error 404--Not Found
From RFC 2068 Hypertext Transfer Protocol -- HTTP/1.1:
10.4.5 404 Not Found
Relevant lines o code from index.html
=====================================
    <FORM ACTION="/greeting/servlet/GreetingServlet" METHOD="POST">
      <P>Your Name <INPUT TYPE="text" SIZE="40" NAME="name"></P>
      <P>Your Email <INPUT TYPE="text" SIZE="40" NAME="email">
      <INPUT TYPE="submit" VALUE="Submit"></P>
    </FORM>
Relevant lines o code from web.xml
==================================
  <servlet>
    <servlet-name>Registration</servlet-name>
    <servlet-class>GreetingServlet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>Registration</servlet-name>
    <url-pattern>/GreetingServlet/*</url-pattern>
  </servlet-mapping>
====================== xxx ======================
I am working this same example from Ch07 of "Prof Java Server Programming-J2EE Edition"





Similar Threads
Thread Thread Starter Forum Replies Last Post
MMS using servlet or jsp monika.vasvani ASP.NET 1.0 and 1.1 Basics 0 July 19th, 2006 06:24 AM
jsp working but servlet not....... rai Apache Tomcat 0 June 23rd, 2005 12:37 AM
hello ,help me find the place of pro jsp cliffwang Pro JSP 3 March 21st, 2005 06:28 AM
How to open a *.pdf file in the browser by jsp pro viren_balaut Pro JSP 0 January 4th, 2004 02:22 PM
I want to buy "Pro JSP" book! fujinova J2EE 0 September 10th, 2003 09:29 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.