简体   繁体   中英

Passing confirmation to JSP from servlet, getting errors

Currently I am attempting to have a page that will return a car, I have a method that creates a new object and passed this to the jsp. The problem I am having the jsp is always expecting the object to arrive resulting in a http status 500.

How do I go about having this object on the page only when the object is created through the servlet. Again this is just to confirm that your request has gone through. My code is below

<h4>
<%  ConfirmationBean confirmationBean = (ConfirmationBean)request.getAttribute("confirmation");
    if( !confirmationBean.getConfirmation().equals("") || !confirmationBean.getConfirmation().equals(null)){
        out.println(confirmationBean.getConfirmation());
    }
%>
</h4>

and the stack trace I am getting is below.

Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:579)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:476)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

check if the return of this request.getAttribute("confirmation") is null

if(request.getAttribute("confirmation")!=null){
         //go ahead
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM