mercredi 5 mai 2021

404 When Passing Parameters

Question: I'm coding some basic servlet and I'm passing parameters in link

http://localhost:8080/Parameters/wypisz_parametry?parametr1=java&parametr2=start&parametr3=javaEE

but when I enter it I get 404 error.

web.xml:

    <?xml version="1.0" encoding="UTF-8"?>
<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_3_0.xsd" id="WebApp_ID" version="3.0">
  <servlet>
    <servlet-name>Parameters</servlet-name>
    <servlet-class>pl.javastart.servlets.wypisz_parametry.java</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>Parameters</servlet-name>
    <url-pattern>/wypisz_parametry</url-pattern>
  </servlet-mapping>
</web-app>

wypisz_parametry class:

    package pl.javastart.servlets;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class wypisz_parametry extends HttpServlet {
private static final long serialVersionUID = 1321321321L;

public void doGet(HttpServletRequest request,
           HttpServletResponse response)    throws ServletException, IOException {
     PrintWriter out = response.getWriter();

     String parametr1 = request.getParameter("parametr1");
     String parametr2 = request.getParameter("parametr2");
     String parametr3 = request.getParameter("parametr3");

     out.println("Wczytanie 3 parametrow z zadania :");
     out.println(parametr1);
     out.println(parametr2);
     out.println(parametr3);
     }
 }

Now that i gave you my question, i'm asking if you if you could please help to find the solution




Aucun commentaire:

Enregistrer un commentaire