1

Is JSF the only option?

The HTML front end uses JQuery as a front-end scripting framework.

HyderA
  • 20,651
  • 42
  • 112
  • 180

5 Answers5

7

You can use a number of technologies to interact with applications. If you want to stay on the Java side, JSF, JSP are two big ones. JSF Depends on a big framework, but there are other frameworks that rely just on JSP/Servlets. You can incorporate JQuery into the HTML/JSP/JSF combinations.

On the other hand you could just use JQuery to send AJAX calls to Servlets that return HTML/Json to the client. The JQuery can then do whatever you want with that.

scheibk
  • 1,370
  • 3
  • 10
  • 19
5

For the new hotness hook your jQuery up to a Java JAX-RS backend using Jersey. Will work very well with jQuery AJAX.

For example, create a POJO like this:

@Path("/users")
public class UsersService {

    @GET
    @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
    public Users getUsers() {
        return UserQuery.getUsers();
    }
}

That says this "service" can provide the UserList in either XML or JSON. Which you can then access via jQuery like this:

<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <title>User List</title>
    <link href="css/base.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <h1>User List</h1>
    <div>
        <ul id="userlist">
        </ul>
    </div>
</body>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript">
    $.getJSON("service/users",
        function(data){
        $.each(data.users, function(i,user){
            $("#userlist").append("<li>"+user.email+"</li>");
        });
        });

</script>
</html>

Simples.

Damo
  • 11,410
  • 5
  • 57
  • 74
1

check my question that asks for something similar, as it is very insightful:

Web User Interface for a Java application

Community
  • 1
  • 1
João Silva
  • 89,303
  • 29
  • 152
  • 158
-1

Take a look at Spring Web MVC framework which is pretty much a standard for java web app development nowadays.

serg
  • 109,619
  • 77
  • 317
  • 330
-1

Check DWR - synopsis from the site:

DWR is a Java library that enables Java on the server and JavaScript in a browser to interact and call each other as simply as possible.

http://directwebremoting.org/dwr/index.html

KingInk
  • 536
  • 1
  • 3
  • 7