Answer the question
In order to leave comments, you need to log in
Error when displaying "Hello World!"?
I'm struggling and can't cope with the simplest, the "printText" method in the Class class, in request.setAttribute
a JSP servlet, displays an error 500, look at the code, what's wrong? Tomcat8, IntelliJ IDEA Ultimate
Class, Servlet:
public class Servlet extends HttpServlet {
public class PrintText {
public String printText() {
return "Hello!";
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
PrintText p = new PrintText();
p.printText();
request.setAttribute("p", p);
request.getRequestDispatcher("/WEB-INF/index.jsp").forward(request, response);
}
}
<html>
<body>
<p>${p.printText}</p>
</body>
</html>
Answer the question
In order to leave comments, you need to log in
Replace the name of the printText method with getText, and the EL expression with ${p.text}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question