I am using Intellij Ultimate to try out basic examples of JSP and Sevlets.
I have a simple Person class:
public class Person implements Serializable {
public String name = "Alexa";
public String getName() {
return name;
}
}
And a Servlet:
public class GenericServlet extends HttpServlet {
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
Person person = new Person();
RequestDispatcher rd = request.getRequestDispatcher("display.jsp");
request.setAttribute("person", person);
rd.forward(request, response);
System.out.println("Passed to display jsp");
}
}
And I am simply trying to print the person name using JSP:
<jsp:useBean id="person" scope="request" class="com.sample.Person"/>
......
<h2>Name of person is: <jsp:getProperty name="person" property="name"/></h2>
<h2>Name of person is: ${person.name}</h2>
I am able to print using first h2 tag but not with second, even when I am able to auto-complete person.name in JSP.
Looking for missing bits here. Thanks!