HyderA
HyderA

Reputation: 21371

How to integrate a website with a Java back end?

Is JSF the only option?

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

Upvotes: 1

Views: 18384

Answers (5)

João Silva
João Silva

Reputation: 91299

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

Web User Interface for a Java application

Upvotes: 1

KingInk
KingInk

Reputation: 536

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

Upvotes: -1

serg
serg

Reputation: 111255

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

Upvotes: -1

Damo
Damo

Reputation: 11540

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.

Upvotes: 5

scheibk
scheibk

Reputation: 1370

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.

Upvotes: 7

Related Questions