Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java Open Source > Apache Tomcat
|
Apache Tomcat General discussion of the Apache Tomcat servlet container. For discussions specific to the Professional Apache Tomcat book, please see the book discussion forum for that book.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Apache Tomcat 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 August 19th, 2007, 11:52 AM
Authorized User
 
Join Date: Jul 2007
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to david_marsetty
Default i am unable to process this application

My application is shown bellow
this is my form.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>David Documents </TITLE>
</HEAD>
<BODY>
<form action="/simple/FirstServ" method="POST">
Name:
<input type="text" name="sname" ><br>
Passwod:
<input type="password" name="spws" ><br>
<input type="submit" name="submit" value="login">
</form>
</BODY>
</HTML>

servletclass

FirstServ.java

import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class FirstServ extends HttpServlet
{
public void doPost(javax.servlet.http.HttpServletRequest req,
                  javax.servlet.http.HttpServletResponse res)
           throws java.io.IOException,
                  javax.servlet.ServletException {
    try{
        res.setContentType("text/html");
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        Connection con=DriverManager.getConnection("jdbc:odbc:oracle" ,"scott","tiger");
        Statement st=con.createStatement();
        PrintWriter out=res.getWriter();
        String name=req.getParameter("sname");
        String pass=req.getParameter("spws");
        int n=st.executeUpdate("insert into mydata values(" + name +"'," + pass +")");
        if(n>0){
        out.println("<html>");
        out.println("<head><title>simple</title></head>");
        out.println("<body>M.David ur data inserted</body>");
        out.println("</html>");
        out.close();
        }else{
            out.println("<html><body>Data inserted failed</body></html>");
        }
    }catch(Exception e){}
    }
}

and my web.xml file

<?xml version="1.0" encoding="ISO-8859-1"?>

<!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>
<servlet>
        <servlet-name>First</servlet-name>
        <servlet-class>FirstServ</servlet-class>
    </servlet>
<servlet-mapping>
        <servlet-name>First</servlet-name>
        <url-pattern>/look</url-pattern>
    </servlet-mapping>
</web-app>

after i run this application in my tomcat5.0
i got this error

type Status report

message /simple/FirstServ

description The requested resource (/simple/FirstServ) is not available.

plz suggist me

M.david
__________________
M.david
 
Old September 4th, 2007, 06:08 AM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 373
Thanks: 0
Thanked 1 Time in 1 Post
Default

You made a fundamental mistake. See the <url-pattern> tag and use that in the action attribute of the <form> tag. As per your configuration the servlet FirstServ is pointed by the url /look. I mean if you call /look it'll execute the FirstServ servlet.

- Rakesh





Similar Threads
Thread Thread Starter Forum Replies Last Post
Server was unable to process request tarduk2004 ASP.NET 2.0 Professional 1 December 12th, 2007 08:37 AM
Server was unable to process request. ---> The num tqbinh .NET Web Services 1 March 22nd, 2007 10:14 PM
SoapException: Server was unable to process reques deeptisingh20 ASP.NET 1.0 and 1.1 Professional 1 September 12th, 2006 06:29 AM
Server was unable to process request. Kross ASP.NET 1.0 and 1.1 Professional 1 January 8th, 2006 10:49 AM
Unable to attach to the process drdexter33 VB.NET 2002/2003 Basics 3 September 26th, 2004 10:04 PM





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