How to learn high-level Java web development concepts [closed] - java

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I have some experience writing web applications in Java for class projects. My first project used Servlets and my second, the Stripes framework.
However, I feel that I am missing the greater picture of Java web development. I don't really understand the web.xml and context.xml files. I'm not sure what constitutes a Java EE application as opposed to a generic Java web application. I can't figure out how a bean is different from an ordinary Java class (POJO?) and how that differs from an Enterprise Java Bean (EJB). These are just the first few questions I could think of, but there are many more.
What is a good way to learn how Java web applications function from the top down rather than simply how to develop an application with a specific framework? (Is there a book for this sort of thing?) Ultimately, I would like to understand Java web applications well enough to write my own framework.
Update: To be clear, I am not interested in learning how to use specific frameworks (for instance, Spring or Java EE). I am looking for an explanation of the internals of a generic Java web application.

I recommend Head First Servlets and JSPs by Bates and Sierra. Some don't care for the whimsical style, but it is a solid intro to Java EE. EJB's aren't covered, but one book can't do everything.

I don't really understand the web.xml and context.xml files.
The web.xml file is just a configuration file which instructs the application server under each which filters/servlets to load and instantiate and on which url-patterns those should be invoked.
The context.xml is just another configuration file which instructs the application under each where the webapp is located at the local storage system and on which domain/URL context it should listen.
The appserver parses both files on startup and takes actions accordingly.
I'm not sure what constitutes a Java EE application as opposed to a generic Java web application.
It's unclear what your own definitions of "Java EE application" and "Generic Java Web application" are. To answer such a question (even though yourself), you'll need to lookup and/or redefine the definitions. But in general, there are two kinds of Java EE applications: web applications (usually to be deployed in flavor of WAR's) and enterprise applications (usually to be deployed in flavor of EAR's). The major difference is that the second involves EJB's and thus require to be run on an application which supports EJB's (e.g. Tomcat doesn't).
I can't figure out how a bean is different from an ordinary Java class (POJO?) and how that differs from an Enterprise Java Bean (EJB). These are just the first few questions I could think of, but there are many more.
Those are just terms which are been applied dependent on the purpose (and history) of the class in question. The term "POJO" is a (generally negative) term representing a Javabean which is just a value object (totally no business logic, pure bean with only getter/setter methods) and is generally a model object which is part of a "legacy" program which uses EJB/Hibernate. Some call it VO (Value Object), others call it DTO (Data Transfer Object), again others just stick to "javabeans".
What is a good way to learn how Java web applications function from the top down rather than simply how to develop an application with a specific framework? (Is there a book for this sort of thing?) Ultimately, I would like to understand Java web applications well enough to write my own framework.
Start with Head First Servlets & JSP. Read the Servlet API and try to implement one yourself. Knowledge of HTTP is however mandatory as well. Read/debug/play/hack the source of existing open source Servlet API implementations (e.g. Tomcat). Read/debug/play/hack the source of existing open source (MVC) frameworks (e.g. JSF). Try to understand how they works and then try to do it better. For the learning path ("What skills do I need?") I've posted a similar answer before here.

The best way to explore the Java world and to connect all the dot’s is to just use one of the frameworks, as all use web.xml, context.xml and Java EE components (all can persist the Pojo entity beans). As you already know the Stripes framework, I can recommend this book (it’s short an handles all the aspects you named):
Stripes: ...and Java Web Development Is Fun Again,
by Frederic Daoud,
Pragmatic Programmers,
ISBN: 1934356212
A more thoroughly approach for a deeper understanding of these Java EE technologies would be to gain all the knowledge necessary for passing these two Java Certification exams:
Sun Certified Web Component Developer (SCWCD)
Sun Certified Business Component Developer (SCBCD)

See the answers to this question.
Also, I build web apps with Java without using the traditional servlet-based approach at all. I generally use Restlet to build RESTful web apps which I run as standalone Java apps with embedded HTTP servers. This article details some of the advantages of using an embedded HTTP server instead of building a traditional Java web app and deploying it in a container / app server. If you're building a "regular" web application as opposed to a RESTful one (not necessary, IMHO), then check out Play, a cutting-edge high-level MVC web framework which allows for rapid development with much less ceremony.
Good luck!

If you're trying to get a good handle on what all of the bits are for in the Java EE spec and which of them you might use for web applications, I strongly suggest taking a look through the Java EE Tutorial. You can probably skip over the in-depth capabilities descriptions since you mostly want to get a high-level overview of each technology, its capabilities, and how it fits with everything else. However, do read through some of the examples that tie together the Web Tier, EJB's, and Persistence.

Get "Heads First Servlets and JSP" - it's a semi-weird looking book, but the content is excellent and people use it as a prep guide for the Sun Certified Web Component Development exam (SCWCD) for which the SCJP (Sun Certified Java Programmer) exam is a pre-requisite.
You should seriously consider getting both the SCJP and the SCWD, at least because you force yourself to get through the material. They won't guarantee to make you a better programmer than what you are now, but they will expose you to Java/Java EE material that is (usually) only available at the workplace.
I've also used some self-paced online courses with webucator.com, and I'd suggest you check their SCJP 5.0 and Web Services courses (the later similar but distinct from Web component development.)
There are frameworks out there that make Java EE web development less painful, but the more you know the guts of them, the greater your understanding of it will be (and you will be much better equipped to use it or its alternatives.)
Another book that you might want to check (perhaps you should check first) is Downey's Web Development with Java: Using Hibernate, Jsp and Servlets. It is out of print now, but there are used copies available for sale. Prof. Downey used this book to conduct a Java EE course at Florida Int. University covering the start and end of developing database-driven web applications. *
You should have some knowledge of SQL and relational database theory, even if you end up using OR mappers. This type of knowledge goes hand in hand with developing non-trivial web applications.

The irony is that the reason you want to know all about Java web development is the same reason that you are having so much trouble getting a handle on it. Why is it that every Java developer wants to write a web framework?
Seriously, though, there is an extremely long history to Java web development. From the beginning, there has been a fight between heavyweight and lightweight. It all started with EJBs and that they mostly sucked. The alternative to all that was struts. And that kind of sucked too. It all spiraled out from there with Spring bringing in the wave of dependency injection, then JSF was more complicated than ever. Finally, Rails showed up and just ran circles around everything Java had to offer. The current crop of Java frameworks show some of the legacy and battlescars of the previous generation, but it has gotten better. In general there's less configuration, and an attempt be leaner, with fewer dependencies and layers.
To answer your question more directly though, just look into the difference between a servlet container like tomcat, and a full Java EE application server like Glassfish or JBoss. It basically boils down to whether or not you want to use EJBs. If you plan on writing your own framework, you won't. Basically, just look at how servlets/servlet containers work. Beyond that, look at the source code of other frameworks.

Related

Server-side Java dev on Windows

I'm carrying out a feasibility study on writing, let's say it's a lightweight run-in-browser MMORPG. (It's not exactly an MMORPG, but would take longer to explain, and the requirements are similar.) I'm trying to figure out the required technology stack.
Client side, it runs in the browser, so the client is Javascript. That was nice and easy :-)
Server side, I'm looking at Java. The common Lamp stack was designed for RESTful applications, as I gather were typical Java web frameworks, and this application is different - it needs a continual stream of data going back and forth between the server and all the clients. I think what I need in this case is Java of the non-framework, full no-holds-barred Java EE variety, someone please correct me if my understanding is incorrect or incomplete? I would need something that is commonly available on reasonably cheap hosting, Java EE fits this description, right?
(Figuring on using MySQL for the database, as this is what's most commonly available. Also I might actually write the code in Scala, being a Java-compatible but supposedly slightly nicer language. I assume neither of these makes any difference?)
Supposing I were writing a website in Lamp, doing at least the initial development on Windows, then I'd install Xamp, which gives you a running copy of the entire server stack right there on your desktop, so you can just alt-tab back and forth between your editor/IDE and browser for testing.
Now my question is: What's the best equivalent setup for Java, for developing something like this on Windows?
Right, in a sense it is. What I think I'm really saying is that almost all discussion of server-side Java seems to talk about JSP, EJB, Glassfish, Google app server etc which are frameworks in the sense that they put restrictions on what your code can do, whereas Java EE puts no such restrictions, you can use as much or as little of the standard library as you want, but it doesn't stop you running arbitrary persistent Java code. Is that correct?
You've thrown out a bunch of terms there:
Glassfish is an application server that implements (all of) Java EE.
JSP is a specification that is part of Java EE, and implemented by application servers such as Glassfish as well as web servers such as Tomcat and (I think) Jetty.
EJB is another specifications that are part of Java EE. It is typically implemented by application servers.
"Google app server" is really "Google Application Engine" (GAE), and is really a platform for implementing web servers in a cloud computing environment. If that's not what you want / need to do, GAE is probably a blind alley for you.
Glassfish, JBoss, Tomcat, Jetty and so on are all platforms that implement some or all of Java EE. None of them stop you implementing arbitrary persistent Java code.
GAE on the other hand does restrict what you can run, because the platform only allows you to run standard Java classes in a whitelist. If your "arbitrary" code depends on other standard Java classes, you are out of luck. (And hence my warning about blind alleys.)
And of course, there are various other Java-based frameworks that are targeted at web development in one form or another. Some are compatible with Java EE servlets and other EE technology, and some have gone off in a different direction.
My recommendation would be to start with something straight forward using plain servlets on a stock platform. Only look at the high performance stuff if and when performance looks like it will be a real concern (not just a "nice to have"). It is better to have a simple and non-scalable prototype, than a high performance solution that you don't have the time and skills to get working. And you can treat the prototype as a learning exercise.
A little hard to tell from the requirements given, but I would look at the following based on your description:
http://www.playframework.org/
http://www.zkoss.org/
http://code.google.com/webtoolkit/
Play Framework is a nice web-centric framework that provides a complete stack (you can code in Java or Scala). ZKoss (ZK) and GWT both provide user interface frameworks. ZK, GWT, and Play all run nicely in Tomcat/MySQL and should work just fine in typical Java/MySQL hosting environment.
... not sure what your definition of 'cheap' is but, that and 'no holds barred Java EE' don't exactly go together. Also, 'frameworks' by themselves don't put restrictions on running any arbitrary java on the server side. When I say 'frameworks' I mean Spring, Struts, etc. Servers will be a little different story. If you need EJBs you'll need Glasfish or JBoss or another EJB compliant container. Hosting with these will be more expensive compared to getting by with Tomcat. IMHO easiest and quickest way to get started is with NetBeans. Comes with Tomcat and / or Glassfish out of the box, all you need is a db.

What may be the difficulties, if any, with the web applications developed in Java EE?

I have a few questions to understand better Java's usage in context of web applications:-
Is Java EE web development suitable for small start-up (with less human resource) looking to develop an web application ?
What kind of difficulties may arise in Java EE web development, deployment & maintenance ?
What kind of things should be kept in mind/ considerations to be made when moving from PHP background to Java ?
Why Java web applications are not so popular today? ( or in case I perceived it wrongly, please list any major deployments beside linkedIn and ebay)
and Finally, What are some of the most important things to learn before starting web development in Java EE ?
Thank you
Generally the answer to the question of "what technology to use" is "the one which you have most experience with". However, Java EE is huge and clunky, and definitely not good for rapid prototyping, which you will be doing if you're doing a startup.
Personally I would recommend a more modern and dynamic environment. If you're coming from PHP, you should be able to pick up Ruby on Rails or Django (Python) easily. These two choices are in my opinion orders of magnitude better than Java EE. If you want to stick with Java, at least go with the Play framework then.
Is Java EE web development suitable for small start-up (with less human resource) looking to develop an web application ?
Yes, I worked in a startup where I was the only full time programmer.
What kind of difficulties may arise in Java EE web development, deployment & maintenance ?
The same as in any other web development shop. Of course, the problems have their Java flavor. For instance, one bug we discovered was caused by different minor version of JDK used on the live system than on our test system.
What kind of things should be kept in mind/ considerations to be made when moving from PHP background to Java ? Do not code the PHP way. Java's strength is OOP and its many libraries/ open source frameworks. Use that.
Why Java web applications are not so popular today? ( or in case I perceived it wrongly, please list any major deployments beside linkedIn and ebay)
I don't know why you think that, but Java is used everywhere. It is one of the few languages that Google officially uses. They use PHP as well, but it has a "lower" status.
and Finally, What are some of the most important things to learn before starting web development in Java EE ? Use Java's strong points which I mentioned above.
Updated after comment
I cannot make the choice for you. If you are in doubt and in a big hurry you should not go with Java. This is common sense. However, it is an opportunity for your team to learn and grow. Maybe there is a PHP/other client for Cassandra. I knew a former PHP programmer in a startup, who switched to Java. Not saying anything bad about PHP programmers in general, but he did all kinds of strange things, such as not leveraging the power of Java web frameworks and writing lots of procedural code mixed with HTML and SQL. Obviously there are lots of Java programmers who would do the same thing. The point is that your team will probably learn new ways to do things and benefit from it in the future.
Allow me to answer these from the perspectives of a developer/architect in a small start-up, experiencing a bunch of these issues.
What kind of difficulties may arise in Java EE web development, deployment & maintenance ?
How do you decide on which toolset/framework to use? Do you need an IDE? Which version control system and why? Do you want to develop at some place and deploy somewhere else, or develop directly on the server? Do you buy a linux box for this, or rent some cloud? How much do they cost, in terms of licenses and training?
What kind of things should be kept in mind/ considerations to be made when moving from PHP background to Java ?
How would your servlet send out an e-mail? It's much simpler in PHP. Need secure transfer of encrypted objects? Java is your friend. What about session tracking? Use cookies, or have a dedicated class do it? How do you access the database? Want to use hibernate? What other tools is hibernate dependent on? What are their costs (license+learning)? Can you use JDBC directly? What are the pros and cons? Which db to use to why.
Why Java web applications are not so popular today? ( or in case I perceived it wrongly, please list any major deployments beside linkedIn and ebay)
I am not sure if this is the case, but possible reasons could be the availability of .net and integration with C# based systems and Apple ditching Java from its SDK. But that is my speculation, don't quote me on it. I am developing a large scale system myself with Java 6.
and Finally, What are some of the most important things to learn before starting web development in Java EE ?
(This is my opinion) have a test or trial set up of the entire architecture. Is the GUI web-brower based? Is it an applet? Standalone application talking to a server? JNLP system downloading archives and JRE off the net? You will find some stuff do not work on Windows 7, some do not on Vista, W3C have deprecated the applet tag from HTML but Sun/Oracle asks you to use it, different browsers do not support contents of your style sheet, etc.
Firewall set up is another major challenge - you start using thread pooling using Spring libraries and your capabilities to use DBvisualizer to check on DB tables are gone! Now you need a DBA and a sys-admin to fix these who you do not have!
Personally I found the LAMP architecture (Linux-Apache-MySQL-PHP) the fastest way to go for smaller applications, but if you need heavier guns for your app (security, GUI with swing, multithreading, etc), replace the P in LAMP with a tomcat container. The hardest thing I find is to judge the value of a tool in the context of my application - I do not need a tool that generates Java files with getter/setter methods given a list of variables - to me that is yet another level of indirection, but then JUnit in eclipse is helpful for debugging.
Just shared some of my thoughts - hope this helps, - M.S.
For a startup an interesting choice could be the Lift web framework, which is used for developing "Java Web Applications" (although in Scala).

Start with Java (JVM) ecosystem

I have came from another question to this one:
How can one start with Java (JVM) ecosystem? What are beginner, intermediate and advanced knowledge-bases (bags!)? To be honest Java ecosystem was always a bit confusing to me, so it would be very helpful to provide some "reference references" and "defacto tutorials" for learning (curve!) JVM.
Note: I want to use JVM with Scala (or Clojure) but not Java itself.
I am a C# developer (WPF, Windows Forms, ASP.NET, Web Services, ... like that).
The Java Tutorial is a good place to start.
Update: you have enough questions for about a dozen posts here ;-) Honestly, you should do some research yourself (Google is your friend), then ask more specific, targeted questions; that would yield better results. (e.g. I don't think anyone can answer your question regarding Swing or JavaFX without more specific details about what you are trying to achieve.) I try to give a few pointers below, about areas I know to some extent.
for servlets and other web frameworks, here is a bunch of tutorials.
Tomcat and Jetty are both application servers.
there are a lot of different web frameworks, because different people have differing preferences, ideas and style, so many have created their own framework. It can be confusing, but at least there is choice :-)
for persistence, apart from JDBC, ORM frameworks are another strong option. I use Hibernate and I can recommend it; in a bigger project it can make your life much easier. Ultimately it depends on your specific project and constraints; there is no single right choice.
AFAIK Java has no equivalent of LINQ.
See also this post for further recommendations.
Java based web applications need to run inside of a web container such as Jetty or Tomcat.
You build your app and deploy it to the container which hosts the application at runtime.
Pure/plain JDBC should only be used directly by simple applications or integration layers that do not have access to the class model.
Most applications that I have seen have used some kind of Object Relational Mapping framework which models the entities as classes at a higher level than plain old JDBC.
Popular O/R frameworks include:
hibernate
toplink
datanucleus
cayenne
For web based development, you could start with AppFuse, see the quickstart guide.
AppFuse is a templating system that generates the skeleton of an application for you.
Then look deeper into what has been generated, and see what frameworks they are using.
AppFuse lets you choose between different technology stacks, so you could compare.
I haven't seen AppFuse support for Guice or GWT.
Guice is a Dependency Injection framework, others that could be used instead are Spring or picocontainer.
Another investigative approach that you could try would be starting with AndroMDA, which is a model driven architecture framework - you start with a UML model and then generate or forward engineer a working application.
AndroMDA also lets you control the choice of the underlying framework implementations by configuring different cartridges, once again you should dig deeper to see what they are using in the generated application.
If you are looking for a basic introduction, then the Java Tutorials are nice. To do other things like Java Web Development, then your going to need to consult google for the respective technology since they vary so widely.
One book though that I highly recommend taking a look at is Java Concurrency in Practice
Yeah, it is almost impossible for new guys to get started. This is going to drive away a lot of developers, and Java is in danger of not having constant new bloods. The old farts would love that, it's great for career security, and that's why they are making Java more and more complicated.

What do I need to learn to build a web app in Java? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
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.
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.
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.
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.
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.
For basic simple java based web-app follow below things
Install IDE (eg. eclipse,netbeans)
Install web/application server (eg. Tomcat/Jboss)
Configure server in IDE
Create new dynamic web project with JSP/Servlet
learn/develop and run sample applications which includes advance technology like Spring,Struts,Hibernate,EJB etc.
I believe design is more important than technology, so keep learning design patterns. all major frameworks are based on different design pattern.
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.
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.
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.
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..
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 Java EE app server.
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.

Java development for the web [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
I'm looking to start developing for the web using Java - I have some basic Java knowledge, so that's not a problem, but I'm at a loss when it comes to deciphering the various technologies for use in web applications.
What options are available to me? How do they work? Are there any frameworks similar to Django/Ruby on Rails which I could use to simplify things?
Any links which could help with understanding what's available would be much appreciated.
Java frameworks come in two basic flavors. One is called the "Action" Framework, the other the "Component" Framework.
Action frameworks specialize on mapping HTTP requests to Java code (actions), and binding HTTP Requests to Java objects. Servlets is the most basic of the Action Frameworks, and is the basic upon all of the others are built.
Struts is the most popular Action framework, but I can't in good conscience recommend it to anyone. Struts 2 and Stripes are more modern, and very similar to each other. Both are light on the configuration and easy to use out of the box, providing very good binding functionality.
Component Frameworks focus on the UI and tend to promote a more event driven architecture based on high level UI components (buttons, list boxes, etc.). The frameworks tend to hide that actual HTTP request from the coder under several layers. They make developing the more advanced UIs much easier. .NET is a component framework for Windows. On Java, the popular component frameworks are JSF (a standard) and Wicket.
As a rule, if you're creating a "web site". that is something more akin to presenting information (like a blog, or a community site), the Action frameworks work better. These sites tend to be simpler, get bookmarked often, require "pretty URLs" etc. This is generally easier to do with an Action framework.
Component frameworks are much better for things like back office applications with lots of UI elements and complicated workflows. You'll find, particularly with tooling, that these style of apps will go together faster using a component framework. But component frameworks have more complicated request workflow, sometimes relying on hidden state, lots of POST actions, etc. Many have "horrible" URLs, and sometimes create pages that are difficult to bookmark.
Both frameworks can be used for both tasks, just some are more suited to the task than others.
None of these frameworks directly address persistence, but many have extension modules or idioms that work tightly with JPA/EJB3 or Hibernate.
Your basic java web technology is servlets. Servlets let you write Java code that responds to various HTTP events (doGet, doPost, doPut, etc). They're generally used for controllers in the MVC architecture.
Link: http://java.sun.com/products/servlet/
JSP lets you write HTML with embedded Java instead of the other way around (in servlets). JSP has been extended via JSF to incorporate more recent architectural advances. This is in the same line as PHP and ASP. This is the view portion of the MVC architecture.
Link: http://java.sun.com/developer/technicalArticles/GUI/JavaServerFaces/
A lot of more complex applications utilize Enterprise Java Beans (EJB) for session management, clustering, etc. This isn't a web technology, per se, but you see it go hand-in-hand when dealing with more complex webapps. Alternatives include frameworks such as Spring.
EJB: http://docs.jboss.org/ejb3/app-server/tutorial/
Spring: http://www.springframework.org/
Also, you'll want to familiarize yourself with ORM technology (after servlets and JSP/JSF). The leading ORM framework is currently Hibernate. This lets you map SQL tables to java objects and interact with them accordingly. This is more advanced stuff so save it for when you're trying to get your head around EJB/Spring, etc.
Link: http://www.hibernate.org/
edit: I forgot to define ORM. It stands for Object Relational Mapping/Mapper (whatever version of "Map" you feel like using :)
Start with JSP backed by logic in Java classes. Or use servlets.
The advantage of using JSP and Servlets is that you gain knowledge of what all the frameworks do under the hood. And that understanding is crucial to figure out how to do X in that particular framework.
Furthermore, JSP is very easy. You can easily see what you're doing and very easily see it when you mess up the view with business logic.
And quite a lot of frameworks (Struts, Spring MVC) use JSP as their view technology. It's a natural first step in web development using Java.
I don't know if there's anything quite as nice as Django for Java, but Spring has a light-weight web framework built on J2EE
http://www.springframework.org/about
A flexible MVC web application
framework, built on core Spring
functionality. This framework is
highly configurable via strategy
interfaces, and accommodates multiple
view technologies like JSP, Velocity,
Tiles, iText, and POI. Note that a
Spring middle tier can easily be
combined with a web tier based on any
other web MVC framework, like Struts,
WebWork, or Tapestry.
something like grails ?
there is also the projects from spring
You'll need to start with servlets and JSP. There are many web frameworks in Java and all of them are based on these two technologies.
You could try Jboss Seam : http://www.seamframework.org/Documentation/GettingStarted
If you are using Eclipe as your IDE there is good integration via Jboss Tools or you can use the Seam-Gen tool that comes with Seam. This allows you to define a database table (or tables) and with a few easy commands, build an entire runnable web project from it. It's a nice way to get the ball rolling.
Also Java Server Faces
http://en.wikipedia.org/wiki/Java_Server_Faces
This is a very open-ended question. The short answer is "yes" there are frameworks, libraries and standards to do everything from writing things at the HTTP request level up to content management systems in Java.
You can also use other languages (e.g. Python, Ruby, etc) on the JVM for that matter.
For some of the Java-only technologies, investigate JSP/Servlets, Struts, Struts2 (which is the updated version of Webwork), Spring MVC, Tapestry, web4j, Wicket.
There are other frameworks built on the JVM but use languages other than Java such as Grails.
To get started I would download Eclipse (latest version) and Tomcat. Create a new web application in Eclipse. There are guides that can get you started.
Start with learning how JSPs and Servlets work, these are a bit low level and aren't really a framework, but will let you get up and running quickly. From there investigate and choose your framework.
Spring MVC is pretty easy to get set up and going. I'm certain there are others.
If you already know Ruby On Rails, you can use it with JRuby and deploy to a Java server (like Tomcat) with Warbler.
In pure Java, Wicket has a good approach and is getting quite popular.
Before studying those frameworks, why not study first where it all started? Try programming with servlets first, so you could a peek at the core of most of those java web frameworks. It would help you understand J2EE better.
J2EE is the standard. You can use this to build apps with Java Server Pages, Servlets and EJBs.
Struts is also a very popular framework that uses JSPs and Servlets. Its a bit tricky to get setup but it is a very good option for mid size sites.
http://en.wikipedia.org/wiki/Struts
In general Java is more component-based, i.e. you don't have frameworks that do it all for you (you'll probably have to pick a database access framework yourself, for example). For Data Access I'd recommend Hibernate or iBATIS.
For the front-end there are literally hundreds of frameworks around. Investigate JSF, Wicket, Struts 2, Stripes - whichever one you use depends on your specific needs as they all have different strengths.
And for a business layer I'd recommend the Spring Framework, which is very comprehensive and has a great reference guide / tutorial :)
I learned Java in college back when it was in version 1.1.5. I recently started trying to program for the web, but it didn't make sense until I read Head First Servlets and JSP. There are way more things involved in web development with Java than I ever realized, and without this book, I would have quit and just used PHP.

Categories

Resources