Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jan 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    405 error in servlet application

    dear all,
    i 'm getting 405("HTTP method get does not supported by this url" )
    i am posting all my codes here .plz check out whats the problem.
    The code for "web.xml" is:
    <web-app>
    - <servlet>
    <servlet-name>three</servlet-name>
    <servlet-class>LibraryServlet</servlet-class>
    </servlet>
    - <init-param>
    <param-name>p1</param-name>
    <param-value>sun.jdbc.odbc.JdbcOdbcDriver</param-value>
    </init-param>
    - <init-param>
    <param-name>p2</param-name>
    <param-value>jdbcdbc:manas</param-value>
    </init-param>
    - <init-param>
    <param-name>p3</param-name>
    <param-value>System</param-value>
    </init-param>
    - <init-param>
    <param-name>p4</param-name>
    <param-value>manas</param-value>
    </init-param>
    - <servlet-mapping>
    <servlet-name>three</servlet-name>
    <url-pattern>/db</url-pattern>
    </servlet-mapping>
    </web-app>
    my code for html i.e; "dbase.html" is:
    <HTML>
    <BODY BGCOLOR="#99CC66">
    <CENTER><H1>ACCOUNT CREATION FORM</H1><BR><BR>
    <FORM METHOD="POST" ACTION="http://localhost:8081/databaseapplication/db">
    ROLL NO. :<INPUT TYPE="text" NAME="t1"> <BR><BR>
    NAME :<INPUT TYPE="text" NAME="t2"><BR><BR>
    ISSUE NO. :<INPUT TYPE="text" NAME="t3"><BR><BR>

    <INPUT TYPE="submit" VALUE="create">
    </FORM>
    </CENTER>
    </BODY>
    </HTML>
    and my code for the servlet is:
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.sql.*;
    public class LibraryServlet extends HttpServlet
    {
    Connection c;
    PreparedStatement ps;
    public void init(ServletConfig config)
    throws ServletException
    {
    String d=config.getInitParameter("p1");
    String cs=config.getInitParameter("p2");
    String u=config.getInitParameter("p3");
    String p=config.getInitParameter("p4");
    try
    {
    Class.forName(d);
    c=DriverManager.getConnection(cs,u,p);
    ps=c.prepareStatement("INSERT INTO LIBRARY VALUES(?,?,?)");
    }
    catch (Exception e)
    {
    System.out.println(e);
    }
    }//init
    public void doPost(HttpServletRequest request,HttpServletResponse response)
    throws ServletException,IOException
    {
    response.setContentType("text/html");
    PrintWriter out=response.getWriter();
    int rl=Integer.parseInt(request.getParameter("t1"));
    String nm=request.getParameter("t2");
    Float iss=Float.parseFloat(request.getParameter("t3"));
    try
    {
    ps.setInt(1,rl);
    ps.setString(2,nm);
    ps.setFloat(3,iss);
    ps.executeUpdate();
    out.println("<HTML>");
    out.println("<BODY BGCOLOR=red>");
    out.println("<H1>Account Created Successfully.</H1>");
    out.println("<A HREF=dbase.html>ONE MORE ACCOUNT CREATION.</A>");
    out.println("</BODY></HTML>");
    out.close();
    }
    catch (Exception e)
    {
    System.out.println(e);
    }
    }
    public void doGet(HttpServletRequest request,HttpServletResponse response)
    throws ServletException,IOException
    {
    doPost(request,response);
    }
    public void destroy()
    {
    try
    {
    ps.close();
    c.close();
    }
    catch(Exception e)
    {
    System.out.println(e);
    }
    }
    }

    when I deploy,i get the main page i.e; "dbase.html",after that I get 405 errror.
    I am using Tomcat5.5,jdk1.6,internet xplorer. plz help me find out the problem.
    Last edited by Manas Das; 01-21-2009 at 06:13 PM. Reason: some mistakes

  • #2
    Regular Coder
    Join Date
    Jan 2009
    Location
    india
    Posts
    145
    Thanks
    0
    Thanked 5 Times in 5 Posts
    Don't cross post same questions...
    Stick to the original thread http://www.codingforums.com/showthread.php?t=156658


  •  

    LinkBacks (?)


    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •