RequestDispatcher返回PWC6199:生成的servlet错误

时间:2017-06-18 16:02:51

标签: requestdispatcher

当我尝试使用requestDispatcher时,它不转发URL。我检索到这个奇怪的错误

PWC6199:生成的servlet错误: 源值1.5已过时,将在以后的版本中删除

PWC6199:生成的servlet错误: 目标值1.5已过时,将在以后的版本中删除

PWC6199:生成的servlet错误: 要禁止显示有关过时选项的警告,请使用-Xlint:-options。

我尝试使用sendredirect但没有成功。有什么问题?

我的简单servlet 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>'

我的课程User 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

0 个答案:

没有答案