views:

1021

answers:

7

I've developed a java program that stores entities (using jpa+hibernate) in a mysql database. The entities are users, and other kind of objects. Now I need to write the web side of the application: I need to let user register/login and browse entries that are stored in the db. I'm new to this kind of programming and I don't know what is best to use. I like GWT because it's all about ajax and this could be a benefit for my application (real time update in the webpage), but I don't know if it could be easy to use. I've learned Servlet+jsp at university but I didn't do a thing with them, so consider that every technology you will suggest will be new for me, so the easier the better. I can use netbeans/eclipse as IDE and tomcat/glassfish/jboss/wathever as container.

+2  A: 

JSP/Servlets and GWT are not necessarily competing strategies.

Servlets are a server-side Java process that sit on the back end persistently and accept requests from clients. JSP, like PHP, is a language for dynamically generate page content (it writes a lot of the content like you see when you go to the "View Page Source" option in your web browser). GWT is Java-based, but it actually ends up compiling into JavaScript which runs on the client side and can be used to do AJAX-like things and update parts of the page in realtime. So you could use all three together if you wanted to.

So you could have a Servlet sit on the backend and interact with your database and then dynamically generate your HTML with JSP and use Javascript/GWT to update your generated webpage on the fly based on server updates and user interaction.

Brent Nash
Maybe I'm saying something incorrect, but I think that GWT also support a server-side component based on servlets..
Raffo
Entirely possible, but here's a blurb from the GWT getting started FAQ (http://code.google.com/webtoolkit/doc/1.6/FAQ_GettingStarted.html):"With GWT development, your Java client code gets compiled into equivalent JavaScript that is loaded into your host pages. The generated product is totally independent from the server-side technology that you choose to use in your web application."
Brent Nash
@Brent - That is sort of true, but I suspect that most serious GWT apps end up relying upon GWT-RPC to at least some degree. There is fairly tight integration with Java server code that is very tempting to use.
jsight
GWT is server-side (as servlets) and client-side. the client side compiles to javascript, the server-side compiles normally.
Don Branson
@jsight @Don Thanks for the clarification. My apologies for the mixup.
Brent Nash
+1  A: 

You may want to have a look at this question

I would suggest not using pure JSP. There are so many other, more usable and maintainable solutions out there like seam, wicket, jsf (only with facelets!), and as you mention, GWT.

digitaljoel
+2  A: 

If SEO is irrelevant, and you don't mind slow cycle times (the GWT compiler is really slow, imo), then GWT is pretty nice to work with. The Eclipse Google plugin is pretty nice, too, though it didn't help much with adding GWT-RPC services the last time that I tried it.

Otherwise, I've been really happy with Netbeans, Deploy on Save, and Glassfish. Simple JSP (or JSF, which would be my preference) has a really fast cycle time, and the auto-completion helps greatly. Netbeans 6.8 is already shaping up to be even better, with much better facelets support and the full JEE6 support.

Of course, if your app is small enough, plain JSP can still be pretty simple to get started with. I tend to avoid that for a lot of reasons, though.

jsight
My app is small enough and I can use JSP, but will this be easier/better than using GWT??
Raffo
I bet that JSPs or Facelets would be easier to learn. The learning process has been a little harder for me with GWT, as there seem to be more things to trip you up. Both are pretty simple, though, imo. If SEO is not needed for this project, then just take a look at the tutorials for the two and pick the one that feels best. You are unlikely to go wrong either way. :)
jsight
+1  A: 

It is a lot easier to create a really rich web app (all the AJAX snaziness) in GWT than using JSP's + some framework + Javascript libraries and hacking. The GWT app will probably also be a lot easier to maintain. On the other hand if you just need to get something out the door quickly then JSP's will do the job with less learning curve since you have used them before.

In either case it helps to use a framework of some kind to structure your application (e.g. simple Apache Struts for your JSP app). If you go the GWT route you could try GWT Portlets or one of those mentioned on this question.

David Tinker
+1  A: 

GWT would likely be a good fit for you. You will be able to leverage your current Java skill and minimize your need to deal with html and javascript. It should also be fairly simple to create the server side portion using the GWT RPC framework.

JSPs will most likely only be easier, if you have are doing basic static web pages. Once you move towards a dynamic AJAX based app, GWT probably will be easier. GWT will handle things like creating browser specific javascript, which you would either need to use an additional framework to abstract out or write your own code to handle browser specific special cases.

The GWT4NB plugin for Netbeans works well, should decide to go with Netbeans.

Philip T.
A: 

Given your preferences GWT's steep learning curve is the only factor that can steer you towards JSP/servlet/etc.-based web application. GWT gives you complete tool set to implement AJAX-rich web application and capabilities to communicate with your existing back-end application.

But you will need to embrace desktop-like GUI architecture that still passes through extensive maturing process. Though there are several architectural approaches in GWT that are being established (such as MVP, command, DI and eventbus patterns) their implementations and examples are still being worked on. The terminology, examples, and patterns used are advanced and not very friendly to novice.

If you are ready to embrace this challenge (everything there is doable and far from a rocket science) then your choice should be GWT.

grigory
+1  A: 

An article that describes integration of GWT and JSP: http://aarendar.wordpress.com/2010/01/11/custom-integration-of-gwt-widgets-into-jsps/

Alexander Arendar