开发者

How to learn high-level Java web development concepts [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 f开发者_如何学Goacts 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜