Java EE web development, where do I start and what

2018-12-31 03:16发布

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?

9条回答
何处买醉
2楼-- · 2018-12-31 03:26

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/

查看更多
一个人的天荒地老
3楼-- · 2018-12-31 03:27

(Updated Sep 2018)

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 OCA book or course as well.

Then you can start with JSP/Servlet to learn the basic concepts of Java web development. Good tutorials can be found in Oracle's Java EE 5 tutorial part II chapters 3 - 8 and at Coreservlets.com (Beginner-Intermediate and Advanced, also JDBC). Note that since Java EE 6, JSP is removed from the Java EE 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 to avoid Java code in JSP files? So any tutorials which still cover scriptlets should be skipped as they will definitely take you into a downward spiral of learning bad practices.

We have also 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?


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 Java 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). Java 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 Java 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 Java 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 Java 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. Thus not an old book for Java EE 5 or JSF 1.0 or so.

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:

查看更多
步步皆殇っ
4楼-- · 2018-12-31 03:27

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).

查看更多
旧时光的记忆
5楼-- · 2018-12-31 03:33

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.

查看更多
后来的你喜欢了谁
6楼-- · 2018-12-31 03:37

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 -

alt text http://ecx.images-amazon.com/images/I/5140T7T6WJL._BO2,204,203,200_PIsitb-sticker-arrow-click,TopRight,35,-76_AA240_SH20_OU01_.jpg

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

查看更多
几人难应
7楼-- · 2018-12-31 03:42

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)

查看更多
登录 后发表回答