Redirect page on JasperException

**Main.jsp** String name = session.getAttribute("name").toString(); if (name == "" || name == null) { response.sendRedirect("index.jsp"); } When user access this page by login, there is no problem in main page. But when user want to try to access the page without login, I want to redirect the page to index.jsp, but org.apache.jasper.JasperException: An exception occurred processing JSP page /main.jsp How redirect to index.jsp
I suspect that the name attribute in the session would be null in this case. I don't know this framework in the slightest bit, but I think you are encountering a NullReferenceException. The attribute name is null, and you can't use instance methods (toString()) of objects which are null. In your case the name == null check is completely useless since it can't check for null before the null reference exception happens! My hint: Check session.getAttribute("name") against null before executing toString() on it.

以上就是Redirect page on JasperException的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准