RequestDispatcher вернуть мне PWC6199: сгенерированная ошибка сервлета
Здравствуйте, когда я пытаюсь использовать requestDispatcher, он не пересылает URL. Я получаю эту странную ошибку
PWC6199: сгенерированная ошибка сервлета: исходное значение 1.5 устарело и будет удалено в следующем выпуске
PWC6199: сгенерированная ошибка сервлета: целевое значение 1.5 устарело и будет удалено в следующем выпуске
PWC6199: сгенерированная ошибка сервлета: для подавления предупреждений об устаревших параметрах используйте -Xlint:-options.
Я пытался с sendredirect без успеха. Что случилось?
Мой простой сервлет MyServletSennesal это:
'import com.senesal.moustac.Utilisateur;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;<
public class MyServletSennesal extends HttpServlet {
protected void processRequest(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
System.out.println("Je suis dans la servlet sennesal");
HttpSession unesession = request.getSession(true);
String prenom = request.getParameter("txtprenom");
String nom = request.getParameter("txtnom");
Utilisateur usn = new Utilisateur(prenom, nom);
unesession.setAttribute("utilisateur", usn);
System.out.println("le User est ----->"+usn);
System.out.println("La session est ----->" +unesession);
String myurl="/WEB-INF/PageError.jsp";
RequestDispatcher rd;
if(unesession!=null){
myurl="/WEB-INF/bienvenue.jsp";
System.out.println("Premiere conditionnelle");
System.out.println("L'url --->" +myurl);
//getServletContext().getRequestDispatcher(myurl);
rd= request.getRequestDispatcher(myurl);
rd.forward(request, response);
//response.sendRedirect(myurl);
}else{
System.out.println("Seconde conditionnelle");
//getServletContext().getRequestDispatcher(myurl).include(request, response);
rd= request.getRequestDispatcher(myurl);
rd.forward(request, response);
}
}
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
/**
* Handles the HTTP <code>GET</code> method.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
/**
* Handles the HTTP <code>POST</code> method.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
/**
* Returns a short description of the servlet.
*
* @return a String containing servlet description
*/
@Override
public String getServletInfo() {
return "Short description";
}// </editor-fold>
}
Мой Web.xml
'<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
</web-app>`
Мой файл Bienvenue.jsp
'<%@page import="com.senesal.moustac.Utilisateur"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Bienvue</title>
</head>
<body>
<%
Utilisateur usr =(Utilisateur) session.getAttribute("utilisateur");
System.out.println("On est dans la JSP bienvenu");
System.out.println("Utilisateur ---->" +usr);
if (usr!=null){%>
<h1>Hello Bienvenu</h1>
<%} else {
System.out.println("probleme dans la jsp");
response.sendRedirect("PageError.jsp");
}%>
<% }%>
</body>
</html>'
MyPageError.jsp
'<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Page Error</title>
</head>
<body>
<p>Une anomalie s'est produite </p>
<p><a href="index.html">Retournez au départ</a></p>
</body>
</html>'
Мой класс Пользователь aka Utilisateur
'package com.senesal.moustac;
public class Utilisateur {
private String strprenom;
private String strnom;
public Utilisateur() {
}
public Utilisateur(String strprenom, String strnom) {
this.strprenom = strprenom;
this.strnom = strnom;
}
public String getStrprenom() {
return strprenom;
}
public void setStrprenom(String strprenom) {
this.strprenom = strprenom;
}
public String getStrnom() {
return strnom;
}
public void setStrnom(String strnom) {
this.strnom = strnom;
}
@Override
public String toString() {
String strchaine = this.getStrprenom()+", "+this.getStrnom();
return strchaine;
}
}'
Структура моего проекта Извините за изображение, я сделал его не кликабельным, потому что я не знаю вашу политику в отношении сайтов imagehostigs. Я предпочитаю избегать проблем, если у вас нет проблем с Flickr, обратите внимание на меня, и я получу эту ссылку кликабельной.
https www. flickr _com_photos_ 44522526@ N06_34997725050 _ in_ dateposted-public