Wie bekomme ich Daten von JSP auf servlet-Seite

Ich bin neu auf Servlet-Funktionalität. Ich versuche, einige Daten in der JSP Form und zu drucken versuchen, es in der Konsole mittels Servlet. Aber ich bin nicht in der Lage, das zu tun.

web.xml

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">

  <servlet>
    <servlet-name>controlServlet</servlet-name>
    <servlet-class>com.selenium8x8.servlet.ControlServlet</servlet-class>
  </servlet>

  <servlet-mapping>
    <servlet-name>controlServlet</servlet-name>
    <url-pattern>/*</url-pattern>
  </servlet-mapping>
</web-app>  

Start.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
 <form action="Startup" method="post">
        <input type="text" name="name"/><br>        
        <input type="text" name="group"/>
        <input type="text" name="pass"/>
        <input type="submit" value="submit">            
    </form>

</body>
</html>

ControlServlet.java

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class ControlServlet extends HttpServlet {

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String name = request.getParameter("name");
        String group = request.getParameter("group");
        String pass = request.getParameter("pass");
        System.out.println("Name :"+ name);
        System.out.println("group :"+ group);
        System.out.println("pass :"+ pass);
    }

}

Nach Ausführung, es wirft mir die folgende Fehlermeldung,

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

type Status report

message HTTP method GET is not supported by this URL

description The specified HTTP method is not allowed for the requested resource.
Überprüfen Sie Ihre URL. Welche Adresse hat die Anfrage gesendet?
<form action="/Startup" ?
was ist das Problem passig Daten von JSP -, Servlet-oder eine Seite nicht angezeigt ??
Ich bin immer diese Fehlermeldung jetzt, HTTP-Methode GET wird nicht unterstützt von dieser URL @HussainAkhtarWahid
Ich bin immer diese Fehlermeldung jetzt, HTTP-Methode GET wird nicht unterstützt von dieser URL @sᴜʀᴇsʜᴀᴛᴛᴀ

InformationsquelleAutor Prasanna | 2013-10-16

Schreibe einen Kommentar