I have jsp page -
<html>
<head>
</head>
<body>
<a href="http://localhost:8080/MyProject/Servlet123?usrID=33333">Go to servlet</a>
</body>
</html>
And servlet -
@WebServlet("/Servlet123")
public class Servlet123 extends HttpServlet {
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
// take the ID and retrive all his accounts..
String usrID = request.getAttribute("usrID").toString();
}
}
When I press on the link in the jsp page , it throws exception
java.lang.NullPointerException
in the line - String usrID = request.getAttribute("usrID").toString();
Other details - I use Apache Tomcat 7.0 Tomcat7 .
使用getParameter()
而不是getAttribute()
。
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.