views:

405

answers:

10

Hi,

I've been doing PHP/MySQL web development for a while and I'm fairly competent in it. Lately however, I've learnt Java and fallen in love with it, and I'd really like to do more Java work now.

I've gotten my first opportunity with a client who needs a web 2.0ish web app built, and he has agreed to let me use anything I want to, including Java. However, I haven't done any web dev. in Java before, I've only went through the official Java tutorial, learnt a bit about applets and build a 2D pacman game, and have done some simple work in Google Web Toolkit.

I need to get started with this project in the next 2-3 days max, so I don't have much time to read long books about the topic. This is what I've learnt so far:

  • Setup a Tomcat on my dev machine to work with Eclipse
  • Learnt the basics of servlets, the doPost(), doGet() and init() methods, etc
  • Built a mini MVC app which displays a HTML page, lets you pick something from a dropdown and when you hit submit, it retrieves your submitted value through request.getParameter() in the doPost() function, and then forwards on to a JSP page which shows which value you picked.

I think these are the next few things I'd need to learn:

  • How to access/use databases
  • Sessions and Cookies
  • Possibly more about the syntax of JSP pages.

There seem to be hundreds of topics about Java web dev which I don't know anything about., but I don't have time to learn everything. I need someone to point out any other crucial things I'd need to learn, in order to build this web app (with perhaps 20 screens) using Java and Google Web Toolkit.

Also, I'm coming from a CodeIgniter background which is an MVC framework in PHP that makes things like form validation, sessions management (it uses database sessions), pagination, and common tasks like these very easy. If there is a similar, lightweight framework in Java that can take care of things like this, please mention it as well.

Thanks.

+5  A: 

You should skip basic servlets and use a web framework, from Struts + Tiles (simple to get to grips with - a few hours at most) to Spring, etc. In your case I would also use Hibernate for database abstraction - you don't get up to speed with JDBC in such a short time.

JeeBee
I like Hibernate a lot, but I am not sure that it is a good choice for a beginner in java. Simple sql via jdbc might be the better option.
Jens Schauder
Yeah, I think the problem is that you simply can't learn J2EE to a competent standard in the short timescales he is proposing. JDBC always throws up weird quirks but if he knows SQL it might be for the best indeed. However he should read up on connection pools and so on.
JeeBee
Good advice. I would say pick Spring not Struts and get stuck in straight away with the Hibernate template.
bmatthews68
I agree with the Web framework suggestions, but only due to the very limited time frame and the requirement to become productive "yesterday". Otherwise I'd suggest learning the basics as well.
Joachim Sauer
A: 

I love the Sam's book, 'Teach yourself J2EE in 21 Days'. Awesome for concept reference and basic syntax. Should be pretty cheap by now too.

theG
+3  A: 

As a start, I would recommend you pick up Head First Servlets & JSP. It will give you a nice overview of Java web development. From their you would be better able to pick a web framework to use.

Mr. Will
I've already got that book and gone through the first 3 chapters, but its got heaps of topics that i can't go through in 3-4 days :)
Click Upvote
I see. What I would do then, is try to use the book whenever I got stuck on something. It sounds like you are headed in the right direction.
Mr. Will
+3  A: 

I'd recommend Matt Raible's app fuse .

It will give you a crash course in hooking your app up to a database, using a mvc framework, as well as some of the java build tools. This App fuse demo will show how quickly he gets things rolling.

zmf
The AppFuse tool gives you a number of advantages. It gives you a simple, working web application using the collection of technologies/frameworks that you want. This includes several different frontends (struts1/2, wicket), security (acegi), backends (JPA/hibernate), plus you have the build done.
Tim
+2  A: 

There are so many different Java Enterprise technologies it's pretty hard to know where to start. As previously mentioned, the head first JSP & Servlets book is excellent. I currently work on an Enterprise app that was made years ago with just Servlets. We have migrated over to JSP's as time has gone on but we are not using any of the newer frameworks. So it is for sure a valid way to do it, although dated.

The thing about java, is that most enterprise development is a conjunction of a bunch of different technologies. For example, you could create an app using JSP's for the views with a Servlet back-end, using Hibernate for you DB connections, JDOM for your XML, JUnit for your testing framework, Log4j or AspectJ for your logging framework, Lucene for search, JBoss for deployment (and deployment can be pretty non-trivial) etc. etc. etc. You aren't going to go out and learn all of those technologies in the next 3 days.

What I would suggest is (as previously mentioned) to pick a framework, and there are many to choose from such as Tapestry, JSF, Wicket, Struts, etc. that will abstract away a lot of the underlying technologies. Any java technology you pick will have a good community behind it willing to help.

Another thing to consider, since you seem to be in a hurry to get things working, is that (in my opinion at least) Java is not a FAST language to build things in. It is very verbose and unless you grasp the nuances of good Java web design it is very easy to shoot yourself in the foot. Perhaps you should look at some of the other technologies that are available on the JVM (so that you have all the Java libs available) such as Groovy.

Groovy allows you the ability to program with Java syntax if you choose, or a dynamic Ruby-like syntax. Additionally, Grails is pretty much a Rails clone for Groovy and will let you write a web app in no time at all.

Whatever you choose to do, good luck and welcome to the wonderful world of Java Web Apps.

kgrad
A: 

I would suggest that you try JSP first. JSP is simpler since you don't have to deal with the underlying server technology, not for simple applications atleast. It will get you up to speed. Later, as you gain experience, you can use servlets directly.

It will also fit well with your PHP intuitions.

euphoria83
A: 

I would consider using Groovy on Grails. It's a lot easier to get started and it has a lot of of things that you need built-in. GWT is available via a plugin as is JQuery.

The nice thing about Groovy is that it is basically a superset of Java with the great quick start speed of Rails.

And it will deploy as a .war to your JEE app server.

tegbains
A: 

It's true that starting with Java Web development is not as easy as PHP, especially with CodeIgniter, a framework that I've fallen in love with.

I'd recommend Grails, but first pick up a book on the subject. I've found that in order to get productive quickly you'll need a proper reference. Personally I used The definitive guide to Grails.

Cesar
A: 

I would recommend grabbing a copy of the Servlet 2.5 Specification for reference purposes. It's a fairly nice read, and not too dry for a specification.

It explains about Sessions, Filters, Listeners, threading model, etc...

Also, take a look at the JSP Model 2 architecture (better link) which explains the best use of servlets and JSPs.

I wouldn't recommend looking at Struts or Spring if you only have a few days to get up to speed from scratch. Once you have gained familiarity with servlets and JSPs, then you could look at Spring MVC for an approach that supports easier unit testing for controllers.

toolkit
A: 

You should better learn basic servlet and JSP lifecycles before you touch any framework.. that ll be better, coz you will have a good grasp of the inner workings.. Head First Servlets and JSP is the book you should go for..

lakshmanan