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

0 respostas
hayase

pessoal o que será este erro?

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

estou mandando os códigos

no arquivo web.xml:

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
	 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	 xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
         version="2.4">

	<display-name> GetNpostServlet </display-name>

	<description> Testando exemplo core j2me </description>

	<servlet>
		<servlet-name>GetNpost Servlet</servlet-name>
		<servlet-class>GetNpostServlet</servlet-class>
	</servlet>

	<servlet-mapping>
		<servlet-name>GetNpost Servlet</servlet-name>
		<url-pattern>/GetNpostServlet</url-pattern>
	</servlet-mapping>

</web-app>

depois no arquivo java:

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

public class GetNpostServlet extends HttpServlet
{
	protected void doGET(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
	{
		String acct = req.getParameter("account"), pwd = req.getParameter("password");
		String balance = accountLookup(acct, pwd);
		if(balance == null)
		{
			res.sendError(res.SC_BAD_REQUEST, "Não foi possível localizar a conta...");
			return;
		}
		res.setContentType("text/plain");
		PrintWriter out = res.getWriter();
		out.print(balance);
		out.close();
	}
	
	protected void doPOST(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
	{
		String acct = req.getParameter("account"), pwd = req.getParameter("password");
		String balance = accountLookup(acct, pwd);
		if(balance == null)
		{
			res.sendError(res.SC_BAD_REQUEST, "Não foi possível localizar a conta...");
			return;
		}
		res.setContentType("text/plain");
		PrintWriter out = res.getWriter();
		out.print(balance);
		out.close();
	}
	
	private String accountLookup(String acct, String pwd)
	{
		Connection con = null;
		Statement st = null;
		StringBuffer msgb = new StringBuffer("");
		try
		{
			Class.forName("com.mysql.jdbc.Driver");
			con = DriverManager.getConnection(" ", " ", " "); 
			Statement stmt = con.createStatement();
			ResultSet rs = stmt.executeQuery("select balance from acctInfo where account = " + acct + " and password = '" + pwd + " ' ");
			if(rs.next())
				return rs.getString(1);
			else
				return null;
		}
		catch(Exception e)
		{
			return e.toString();
		}
	}

	public String getServletInfo()
	{
		return "GetNpostServlet 1.0 - www.corej2me.com";
	}
}

não estou tendo problemas de compilação....

estou usando tomcat 4.1 e jdk5

qdo starto o tomcat aparece o seguinte
Severe: Parse Error at line 5 column 17: Document root element ?web-app?, must match DOCTYPE root ?null?
Org.xml.sax.SAXParseException: Document root element ?web-app?, must match DOCTYPE root ?null?.
E mais pra frente aparece
Severe: Parse Fatal Error at line 10 column 4: the element type ?servlet? must be terminated by the matching end-tag ?</servlet>?.
Org.xml.sax.SAXParseException: the element type ?servlet? must be terminated by the matching end-tag ?</servlet>?

as variáveis de ambiente já estão corretamente configuradas...
não estou utilizando nenhuma IDE...
a hierarquia de pastas é a seguinte
[img]
--> GetNpostServlet
--> WEB-INF
--> classes[/img]

obrigada a todos

Criado 23 de agosto de 2007
Respostas 0
Participantes 1