0

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.

like so

Looking for missing bits here. Thanks!

k92
  • 375
  • 3
  • 15
  • Does this solve your problem https://stackoverflow.com/questions/30080810/el-expressions-not-evaluated-in-jsp https://stackoverflow.com/questions/2168832/expression-language-in-jsp-not-working/33722970 – Eklavya May 03 '20 at 09:54
  • @Eklavya yeah it totally did. Wish I had found this sooner. Thanks a lot! – k92 May 03 '20 at 10:06

0 Answers0