Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

HTTP Status 405 - HTTP method POST is not supported by this URL

807601Jun 4 2008 — edited Jun 4 2008
dear all
can u solve my problem.am getting the *"HTTP Status 405 - HTTP method POST is not supported by this URL"* msg from the browser when i press the search button in my form.plz suggest me the solution for my fault.these are the following html,xml,class files:

search.html*
<html>
<head>
<title>Search Page</title>
</head>
<body>
<p align="center"><font size="6" color="#0000FF"><b>Search Module</b></font></p>
<p align="center">&nbsp;</p>
<center>
<form method="POST" action="./emp">
<table border="1" width="43%">
<tr>
<td width="50%">
<p align="right">Employee Name</td>
<td width="50%"><input type="text" name="empname" size="36"></td>
</tr>
<tr>
<td width="100%" colspan="2">
<p align="center"><input type="submit" value="Search" name="B1"></td>
</tr>
</table>
</form>
</center>
</body>
</html>

web.xml*
<web-app>

<servlet>
<servlet-name>jdbc</servlet-name>
<servlet-class>searchModule</servlet-class>

<init-param>
<param-name>driver</param-name>
<param-value>sun.jdbc.odbc.JdbcOdbcDriver</param-value>
</init-param>

<init-param>
<param-name>url</param-name>
<param-value>jdbc:odbc:first</param-value>
</init-param>

<init-param>
<param-name>user</param-name>
<param-value>scott</param-value>
</init-param>

<init-param>
<param-name>pass</param-name>
<param-value>tiger</param-value>
</init-param>
</servlet>

<servlet-mapping>
<servlet-name>jdbc</servlet-name>
<url-pattern>/emp</url-pattern>
</servlet-mapping>

<welcome-file-list>
<welcome-file>search.html</welcome-file>
</welcome-file-list>

</web-app>

SearchModule.java*
import java.util.*;
import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class searchModule extends HttpServlet
{
Connection con;
public void init() throws ServletException
{
String d=getInitParameter("driver");
String u=getInitParameter("url");
String us=getInitParameter("user");
String pwd=getInitParameter("pass");
try
{
Class.forName(d);
con=DriverManager.getConnection(u,us,pwd);
}
catch(ClassNotFoundException e)
{
System.out.println(e);
}
catch(SQLException e)
{
System.out.println("Unable to establish the connection");
}
}//init

public void doGet(HttpServletRequest req,HttpServletResponse res) throws ServletException,IOException
{
String empname=req.getParameter("empname");
res.setContentType("text/html");
PrintWriter pw=res.getWriter();
try
{
pw.println("<html><body><center>");
Statement st=con.createStatement();
String sql="select * from employee where empname="+empname;
ResultSet rs=st.executeQuery(sql);
if(rs.next())
{
pw.println("<h2>Employee Details</h2>");
pw.println("<table border=1>");
pw.println("<tr><th>Employee No.</th>");
pw.println("<th>Employee Name</th>");
pw.println("<th>Designation</th>");
pw.println("<th>Department</th>");
pw.println("<th>Salary</th>");
pw.println("</tr><tr>");
pw.println("<td>"+rs.getInt(1)+"</td>");
pw.println("<td>"+empname+"</td>");
pw.println("<td>"+rs.getString(3)+"</td>");
pw.println("<td>"+rs.getString(4)+"</td>");
pw.println("<td>"+rs.getInt(5)+"</td>");
pw.println("</tr></table>");
}
else
{
pw.println("<h2>Employee Record Not Found</h2>");
pw.println("</center></body></html>");
pw.close();
rs.close();
st.close();
}
}
catch(SQLException e)
{
System.out.println(e);
}
}//doPost

public void destroy()
{
if(con!=null)
{
try
{
con.close();
}
catch(Exception e)
{
}
System.out.println("Connection Closed");
}
}//destroy
}//searchModule

in control panel i selected System DNS and created the name as first and driver as Microsoft ODBC for Oracle

plz suggest me the solution where i committed mistake.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 2 2008
Added on Jun 4 2008
2 comments
210 views