ChatGPT解决这个技术问题 Extra ChatGPT

Java / Jakarta EE web development, where do I start and what skills do I need? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 10 years ago.

I want to learn, at least at a basic level, how to build Java web applications (coming from a .NET background). I would like to be able to build, deploy a simple CMS type application from the ground up.

What exactly do I need to learn?

Tomcat seems to be a good web server for Java.

What options are there for the web? I know there is Hibernate for an ORM.

Does Java have MVC? What about JSP? Can MVC and JSP be together? NetBeans?

Maybe a book that covers all of these?


2
29 revs, 2 users 89%

(Updated Apr 2021)

First of all, "Java EE" has since Sep 2019 been renamed to "Jakarta EE", starting with version 8. Historically, there was also the term "J2EE" which covered versions 1.2 until 1.4. The "Java EE" covered versions 5 until 8. See also Java Platform, Enterprise Edition, History on Wikipedia.

What exactly do I need to learn?

I assume that you're already familiar with client side technologies like HTML, CSS and JS, so I won't go in detail with that. I also assume that you're already familiar with basic Java. Follow Oracle's The Java Tutorials and if possible, go get a OCP book or course as well.

Then you can start with JSP/Servlet to learn the basic concepts of Java web development. Good tutorial can be found in Jakarta EE tutorial chapter 18 'Jakarta Servlet Technology'. Note that since Java EE 6, JSP is removed from the tutorial in favor of JSF and that JSP has basically not changed since then. That's why you could safely use the fairly old Java EE 5 tutorial for this. Most important thing with regard to JSP is the fact that writing plain Java code in JSP files using <% scriptlets %> is officially discouraged since 2003. See also How can I avoid Java code in JSP files, using JSP 2? So any tutorials which still cover scriptlets should be skipped as they will definitely take you into a downward spiral of learning bad practices.

Here on Stack Overflow, you can also find nice wiki pages about JSP, Servlets, JSTL and EL where you can learn the essentials and find more useful links.

Tomcat seems to be a good web server for Java.

It is. It is however limited in capabilities. It's basically a barebones servlet container, implementing only the JSP/Servlet parts of the huge Java EE API. If you ever want to go EJB or JPA, then you'd like to pick another, e.g. WildFly, TomEE, Payara, Liberty, WebLogic, etc. Otherwise you have to use Spring instead of Java EE. It's namely not possible to install EJB in a barebones servlet container without modifying the core engine, you'd in case of Tomcat basically be reinventing TomEE. See also What exactly is Java EE?, How to properly install and configure JSF libraries via Maven? and How to install and use CDI on Tomcat?

I know there is Hibernate for an ORM.

Previously, during the J2EE era, when JPA didn't exist and EJB2 was terrible, Hibernate was a standalone framework and often used in combination with Spring to supplant EJB. Since the introduction of JPA in Java EE 5 (2006), Hibernate has become a JPA implementation. You can learn JPA at Jakarta EE tutorial part VIII. Also, EJB3 was much improved based on lessons learnt from Spring. See also When is it necessary or convenient to use Spring or EJB3 or all of them together?

Does Java have MVC? What about JSP? Can MVC and JSP be together? JavaBeans?

You can, but that's a lot of reinvention of the wheel when it comes to tying the model with the view (conversion, validation, change listeners, etc). Jakarta EE's MVC framework is called JSF. Prior to Java EE 6 it used to run on JSP, which is a fairly legacy view technology. JSP is been replaced by Facelets. You can learn JSF at Jakarta EE tutorial part III chapters 7 - 17. You can by the way also use JSF on Tomcat, you only have to install it separately. Installation instructions can be found at Mojarra homepage. WildFly, TomEE, Payara, Liberty, WebLogic, etc as being a complete Jakarta EE implementation already provide JSF (and CDI, BV, JSONP, JAX-RS, EJB, JPA, etc) out the box, so you don't need to install it separately. See also How to properly install and configure JSF libraries via Maven?

Maybe a book that covers all of these?

There are several books. I would recommend to start with a book focused on Jakarta EE in general, a book more focused on JSF, and a book more focused on JPA. Ensure that you choose the most recent book covering the subject. First investigate the most recent available version and then ensure that the chosen book covers that. Thus do definitely not pick an old book for Java EE 5 or JSF 1.0 or so while there's currently already Jakarta EE 8 and JSF 2.3 available.

Last but not least, please ignore code snippet scraping sites maintained by amateurs with primary focus on advertisement income instead of on teaching, such as roseindia, tutorialspoint, javabeat, journaldev, javatpoint, codejava, etc. They are easily recognizable by disturbing advertising links/banners and JSP code snippets containing scriptlets.

See also:

What is the difference between JSF, Servlet and JSP?

How do servlets work? Instantiation, sessions, shared variables and multithreading

What is the need of JSF, when UI can be achieved with JavaScript libraries such as jQuery and AngularJS


Greate! useful, Thank you. In .Net, usually Wrox Press's book can cover all of knowledges in .net. A very thick book.
Does StackOverflow not have a Pin post feature? Wish it did, so I could pin this answer. Thanks!
There HAS to be an alternative to the JavaEE 5 tutorial. I know Im a noob, and yall prolly very good at it. But... Trying to learn from that tutorial. Its very locked in and dependent on certain settings. So, I need to learn NetBeans. then I need to give up on my server and prolly move to glassfish, trying to find the samplecode to run and learn from wasnt the easyest. I couldnt run on server. instead I was met with something called maven build. I thought I tried which resulted in eclipse going nutz! aparently I need to learn maven as well, and this, that the other and the devils grandmo...
@brat: the answer contains links to alternatives and books.
Well. Only one that covers much. Coreserv... Had to pick up snippets here and there. I went full in with the officiall JavaEE tut now :) Just to find out the SDK one needs to download, to run example code has a GlassFish server that doesnt work with JDK 10 :(, NullPointerException at startup. found a hack stackoverflow.com/questions/47458119/… and so I need to download... and so on and so on. I guess Im just being a bit down and bitchy for having to jump through hoops to learn. :(. They dont make it easy for noobs x). Cheers :)
a
alex

What exactly do I need to learn?

Minimally,

Java the language

Java the API, including JDBC for database access

An IDE, or a text editor + Ant

Java EE, basically, servlets and JSP

A servlet container (such as Tomcat)

Tomcat seems to be a good web server for Java.

It is "decent". If you are not into EJBs, probably you will not need to learn anything else. Glassfish 3 seems to be pretty cool lately, but I have not played with it much yet. Note, it is "more" than a web server. It is a servlet container (meaning it can run apps using servlet technology).

What options are there for the web?

About a zillion different frameworks. Really, choosing one is really "difficult". It is very tempting to try them all, but ultimately unfeasible.

I know there is hibernate for an ORM.

I am somewhat anti-ORM, but Hibernate is what you need if you need a "full" ORM. You can also try "partial" ORMs, such as Spring's JDBC support or iBatis.

Does java have MVC? what about JSP? can MVC and JSP be together? beans?

Yes, most Java web frameworks do MVC. Spring's MVC is nice, but I can't recommend anything else (especially, not Struts 1!). JSP is just an HTML (or XML) templating engine. Old-school JSP, with embedded Java code is uncool; modern JSP with tag files and libraries is pretty good.

I suppose most frameworks will let you use JSP to render your Vs; Spring's MVC and Struts do. Some will let you use something else too (Velocity, Freemarker, etc.).

Beans is just a convention for objects. Basically, it means that you are using getters and setters (or some alternatives) and you are following some rules. These should let your object be manipulated by certain tools. The typical example is a GUI, some tools will let you build GUI components to edit arbitrary beans (i.e. they will render a form to edit its fields).


d
duffymo

You need HTML, CSS, and JavaScript - all the usual suspects for web development.

Tomcat does have a web server built in, but it's a servlet/JSP engine. Apache is the pure web server.

You need to learn JSP, which is a templating language for generating servlets that generate HTML output. You'll want to write them using JSTL, not scriptlets.

If you're doing CRUD applications, you'll need to learn JDBC and relational databases. You should do that before trying Hibernate or any other ORM, because it's the foundation on which they're built.

JavaBeans are just standards for Java objects.

If you're up for it, I'd recommend the Spring framework.


you say tomcat does have a web server built in, what else is it then? i thought all it was is a web server?
@mrblah - Tomcat is a servlet engine. It was made to process servlet classes (which are what jsp's are turned into) and serve the output to a browser. Along with that, it also serves all regular files (images, html, css, etc) just like a web server does. It is comparable to Apache with a php module.
G
Glorfindel

Does java have MVC?

Java has different frameworks like Struts2, Spring MVC

what about JSP?

JSP is template library. There are few alternatives you may try like FreeMarker and Velocity. AFAIK Freemarker is a emerging as good template library. Its lightweight than JSP. Check this FreeMarker: An open alternative to JSP - JavaWorld

can MVC and JSP be together?

I take MVC as a framework mentioned previously. All frameworks have support for JSP but you need to check support for other template libraries in respective frameworks documentation. AFAIK Struts2 to has a very good support for Freemarker.

beans?

I do not know much about it. But using beans we can directly map form data to databases.

Maybe a book that covers all of these?

Each framework has its own book. For Struts2 - Struts 2 in Action

String MVC - Take a look at these questions recommending books for Spring and Spring MVC. Book suggestion for Spring framework and Spring Books: Which one to choose

Fremarker has a very good documentation - FreeMarker Manual

For getting started to web development in Java -

https://i.stack.imgur.com/EbsOe.jpg

http://www.amazon.com/SCWCD-Exam-Study-Kit-Certification/dp/1930110596


A
Avi Flax

I consider most of the traditional Java web development options to be pretty heavy-weight, and there are some good alternatives:

Play is an MVC framework which is focused on being lightweight, straightforward, and enabling rapid development — while sticking with pure Java, as opposed to a more dynamic JVM-based language. It's fairly new but already impressive, and a good community has built up around it quickly.

Grails is an MVC framework, inspired by Ruby on Rails, which is written in, and uses, Groovy, a Java-based scripting language. Grails is mature, robust, and widely respected, with a strong community. Groovy is basically a superset of Java, with better syntax and some great features such as closures, so learning it is a great way to learn Java.

If you need/want to build RESTful web sites/services/applications, Restlet is a fantastic framework — I'm a big fan. It's simple, straightforward, and yet flexible. Great community too.

Google's App Engine is an interesting option as well. It's hosted, which may or may not be of interest, but it has a fairly simple API, and a good SDK.

I'm sure there are others, but these are the ones I can think of off the top of my head.

Good luck, and have fun!


Oh, and I just discovered Prudence the other day: threecrickets.com/prudence
m
mr-sk

I'm a PHP/C programming and I've found groovy enable to me to jump into Java without learning all the classes and paradigms inherent in java programming. Groovy enabled me to be productive quickly, while taking time to learn more about java and all the tools/frameworks/libraries available.


m
mokrzu

If you don't wont to work with html, css, xml, javascript etc..

Try Vaadin framework, it's well documented, easy to learn and enables to make good looking UI in simple way. (just write Java code, of course you need some servlet server, Tomcat or Jetty will be fine)


S
SIVAKUMAR.J

Better you learn java.Then you learn Servlets and JSP.Then go for MVC you go to Struts or Spring or any other java/java enabled framework.


T
Thorbjørn Ravn Andersen

Since you are new to Java I would strongly recommend you learn the basic language first. This will help you regardless of what technology you choose to do your web application in.

A good online resource is the Sun Java Tutorial - http://java.sun.com/docs/books/tutorial/


关注公众号,不定期副业成功案例分享
Follow WeChat

Success story sharing

Want to stay one step ahead of the latest teleworks?

Subscribe Now