All Comments
TopTalkedBooks posted at August 20, 2017

Yes. It is certainly possible, I assume you have been developing most Desktop Application and native Software using Java and so would advise to take up some JSP and Servlets knowledge to dive into web development.

  1. Books for Web Application Development
  2. JSPs and Servlet - Head First Series is good book to start.
  3. Don't Make me thing good book on understanding UI stuffs, which is important for Web Designers.

Try to browse through web-development tags as you will find very useful suggestions there.

TopTalkedBooks posted at August 20, 2017

Use JSTL, as @CoolBeans says. It would look something like this:

In the servlet,

// where myBean is an instance of the class with [get|set]Title
request.setAttribute("myFoo", myBean);

Then, in the JSP,

    <c:when test="${myBean.title eq 'P'}">Peer</c:when>
    <c:when test="${myBean.title eq 'T'}">Team</c:when>

If you're not familiar with JSTL, I'd recommend reading through the JSP section of the Java EE 5 Tutorial, or picking up a copy of Head First Servlets and JSP (it's quite good).

TopTalkedBooks posted at August 20, 2017

As to your problem, anything which you declare locally using the old fashioned scriptlets is not linked with a jsp:useBean. Also, declaring a local scriptlet variable is not visible in the included pages, you need to explicitly put them in at least the request scope. As using scriptlets is a bad practice. I recommend to forget about it at all.

In your specific case, just create a real java bean to hold the data. That is, a class with an (implicit) default constructor and private properties which are exposed by public getters/setters. Here's a basic example:

public class User {

    private String name;

    public String getName() {
        return name;

    public void setName(String name) { = name;


Then you can use a servlet class to preprocess requests. You can use servlet's doGet() method for this.

protected void doGet(HttpServletRequest request, HttpServletResponse response) {
    User user = new User();
    request.setAttribute("user", user); // Store in request scope.
    request.getRequestDispatcher("/WEB-INF/show.jsp").forward(request, response);

Map this servlet in web.xml on an url-pattern of for example /show. This servlet should then be accessible by and its doGet() would be executed immediately.

Then change/create the JSP file show.jsp which you place in /WEB-INF to prevent from direct access (so that clients cannot access it by but are "forced" to call the servlet) with the following line:

<p>User name: ${}</p>

The ${user} refers to the object which is associated with any request/session/application attribute key user. This does behind the scenes jspContext.findAttribute("user"). As the returned User instance conforms the javabean spec, the ${} will invoke the getName() method on the User instance and the EL will display its outcome.

Oh, I should add, you do not need jsp:useBean for this as the servlet has already created and put the desired bean in the scope.

That said, I recommend to start with a decent JSP/Servlet tutorial/book. Examples:

Hope this helps.

Top Books
We collected top books from hacker news, stack overflow, Reddit, which are recommended by amazing people.