Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Java (http://www.programmingforums.org/forum17.html)
-   -   Probelm with program execution in TOMCAT (http://www.programmingforums.org/showthread.php?t=7369)

hemanth.balaji Dec 3rd, 2005 5:21 AM

Probelm with program execution in TOMCAT
 
I am using Tomcat and I am facing the folowing probelm with this simple code to display the parameters entered on a html page by invoking a servlet...

------------------------------------------------------------------------------------------------
My file name(html) is ThreeParamsForm.html which contains (PLaced in my web application folder)
------------------------------------------------------------------------------------------------

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Collecting Three Parameters</TITLE>
</HEAD>
<BODY BGCOLOR="#FDF5E6">
<H1 ALIGN="CENTER">Collecting Three Parameters</H1>

<FORM ACTION= "ThreeParams" method = get>

First Parameter: <INPUT TYPE="TEXT" NAME="param1"><BR>
Second Parameter: <INPUT TYPE="TEXT" NAME="param2"><BR>
Third Parameter: <INPUT TYPE="TEXT" NAME="param3"><BR>
<CENTER>
<INPUT TYPE="SUBMIT">
</CENTER>
</FORM>

</BODY>
</HTML>

----------------------------------------------------------------------------------------
My second file(servlet) name is ThreeParams.java which contains (PLaced in web-inf/src)
-----------------------------------------------------------------------------------------
package coreservlets;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

/** Simple servlet that reads three parameters from the
* form data.
*/

public class ThreeParams extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String title = "Reading Three Request Parameters";
//ServletUtilities.headWithTitle(title) +
out.println(
"<BODY BGCOLOR=\"#FDF5E6\">\n" +
"<H1 ALIGN=CENTER>" + title + "</H1>\n" +
"<UL>\n" +
" <LI><B>param1</B>: "
+ request.getParameter("param1") + "\n" +
" <LI><B>param2</B>: "
+ request.getParameter("param2") + "\n" +
" <LI><B>param3</B>: "
+ request.getParameter("param3") + "\n" +
"</UL>\n" +
"</BODY></HTML>");
}
}


------------------------------------------------------------
and my web.xml contains the following entry for this file
------------------------------------------------------------

<servlet>
<servlet-name>HelloServlet3</servlet-name>
<servlet-class>coreservlets.HelloServlet3</servlet-class>
</servlet>

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

--------------------------------------------------
When I run using TOMCAT I get the follwing error
--------------------------------------------------

HTTP Status 404 - /servlet/coreservlets.ThreeParams

type Status report

message /servlet/coreservlets.ThreeParams

description The requested resource (/servlet/coreservlets.ThreeParams) is not available.
Apache Tomcat/5.0.25

----------------------
How do i make it work
----------------------

Regards.
Hemanth
[ http://javahome1.tripod.com/javahome.htm ]

hemanth.balaji@gmail.com

Ooble Dec 3rd, 2005 7:47 AM

Please use [code] tags - it's almost impossible to read like that.

groovicus Dec 3rd, 2005 8:36 AM

You might not have the file correctly mapped. It is hard to say though since you have half of the mapping for HelloServlet3, and half the mapping for ThreeParams shown. What does the rest of it look like?

I can't tell if there is anything else wrong because the rest of it borders on unreadable... :)


All times are GMT -5. The time now is 4:27 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC