17

I've been asking a lot of people where to start learning java web development, I already know core java (Threading,Generics,Collections, a little experience with (JDBC)) but I do not know JSPs and servlets. I did my fair share of development with several web based applications using PHP for server-side and HTML,CSS,Javascript,HTML5 for client side.

Most people that I asked told me to jump right ahead to Hibernate while some told me that I do not need to learn servlets and jsps and I should immediately study the Spring framework. Is this true? do I not need to learn servlets and JSPs to learn hibernate or Spring?

All of their answers confused me and now I am completely lost what to learn or study. I feel that if I skipped learning JSP and servlets I would missed a lot of important concepts that will surely help me in the future.

So the question, do I need to have foundation/know servlets and JSP to learn spring or hibernate or any other java web frameworks.?

closed as off-topic by gnat, Scant Roger, Ixrec, Matthieu M., user40980 Dec 21 '15 at 14:15

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions seeking career or education advice are off topic here. They are only meaningful to the asker and do not generate lasting value for the broader community. Furthermore, in most cases, any answer is going to be a subjective opinion that may not take into account all the nuances of a (your) particular circumstance." – gnat, Scant Roger, Ixrec, Matthieu M.
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 3
    Note that hibernate is just a database abstraction layer, nothing more, and it can be used to plug a data source into any kind of java app, not just a web application. – Ed Griebel Sep 7 '12 at 0:10
  • 1
    Knowing about servlets and JSP wouldn't hurt, have a look at "Head First - Servlets and JSP". An easy to understand read, but also covers a lot. – Jaydee Sep 20 '12 at 11:38
  • @Jaydee I am currently heading Core Servlets and JSP by Marty Hall + Murach 's servlets and JSP. – KyelJmD Sep 20 '12 at 12:07
  • I don't think this question has been answered adequately. Bear Bibeault, a well known developer and authors insists that one learn JSP and Servlets before learning ANY framework. Anyone care to show why that may or may not be applicable today ? Here is his post - coderanch.com/t/521300/JSP/java/JSP-servlets-struts – Borat Sagdiyev May 11 '14 at 1:02
  • Okay, I got some answers from Bear Bibeault. See these two links - coderanch.com/t/633527/Spring/… and coderanch.com/t/633526/JSP/java/… – Borat Sagdiyev May 11 '14 at 4:18
16

If you've got a good grasp of HTML, CSS, and JavaScript, you have a leg up on many people who end up doing web development. The concepts behind JSP are very similar to PHP. The quirks are different. A servlet is the name for a chunk of Java code that serves a request. That's it really. The whole original Struts framework was a single servlet.

I would add Tomcat or Jetty to your list of technologies to learn. Tomcat is the original Java Servlet Container implementation and happens to also be a fully featured and rather popular web server. GlassFish is built on top of it. I've been using Jetty instead of Tomcat in my newer projects because it's simpler, more flexible, and faster. Jetty was designed to make web services as opposed to web apps. But a web app is just a web service that serves HTML in response to raw HTTP requests, so if you understand HTTP (which you can learn the important parts of in a few hours to a day), it's very easy to work with.

You can make a little web site with Tomcat and JSP (tutorial here or JSF) knowing just what you know and spending a few hours going through tutorials. That way you can start where you are comfortable before stretching out. Then make a javax.servlet.http.HttpServlet that writes "<html><head><title>Hi</title></head><body><h1>Hello World</h1></body></html>" to the response object, list it in your Tomcat web.xml and send an HTTP request it from a web browser. It's not rocket science. All Java web frameworks are variations on those two basic activities.

If you go the Jetty route, it's even less structured. Check out this Hello Jetty example.

If you're just going to make a blog or standard ecommerce site, I'd start with SquareSpace or Wordpress or something. You get so much off the shelf, there's no way to justify custom coding any of that anymore.

The strength of Java for web applications is its reliability, maintainability, and performance. PHP or Ruby/Rails is simpler, but Java will scale as much as you want to go. I am not bowled over by any of the Java web frameworks. When you have a team of people working on a large web application, or you need to use Hibernate, then a framework like Spring really shines. Spring is the most popular. When you have some familiarity with servlets and JSP/JSF, then learn how Spring ties those together with a data model.

If you are making a blog or a content management system, maybe you can get away with a NoSQL database. But I would argue that NoSQL databases are basically just a caching layer on a file system, rather than replacing relational databases. I think it's rare that a project that's a good fit for a NoSQL database is going to be appropriate to develop in Java.

Things that still require custom, high-performance code (in Java, PHP, whatever) are probably going to have a relational/SQL database powering them. I would recommend you get a basic familiarity with SQL and JDBC (Java Database Connectivity) first. After you are comfortable with the world of Java objects, and the world of relational databases and SQL, then you can learn Ebean/JPA (Java Persistence API)/ORM (Object to Relational Mapping) which connects the object world to the relational world.

ORM's are tricky and weird. Most are eventually worth the struggle. Ebean is the simplest one I know. I'm more comfortable with it after 8 months than I am with Hibernate after 12 years. I know a lot of people who use Spring with Hibernate and they don't seem to have any trouble, or even be particularly aware of what Hibernate is or does, so I'd say if you're going to use Hibernate, do it through Spring. Maybe just because I've worked with it longer, I've managed to completely stub-out Hibernate with a couple of hash maps for testing, which is awesome (overview available on request).

You have some of the most important skills already. Take the others one at a time and try not to get overwhelmed.

  • do you have any links or tutorial where I can start learning the said technologies? or perhaps a good suggestion for a book. Most applications that I made uses a RDBMS, from SQL Server to a simple MySQl. – KyelJmD Sep 7 '12 at 3:38
  • I cleaned up my answer and added links as requested. Hibernate/JPA and the various web frameworks take time to learn and master. Most of the other technologies, you know enough about already that you should be able to have working in a few hours or a day. I don't know Spring, but check the documentation on their web site or get a highly rated book on Amazon. – GlenPeterson Sep 7 '12 at 13:27
  • I don't see how this answers the question. Bear Bibeault, a well known developer and authors insists that one learn JSP and Servlets before learning ANY framework. Care to show why that may or may not be applicable today ? Here is his post - coderanch.com/t/521300/JSP/java/JSP-servlets-struts – Borat Sagdiyev May 11 '14 at 1:02
  • @GlenPeterson, "The whole original Struts framework was a single servlet." meaning? Wouldn't it make every http call slow? – Pacerier Aug 21 at 3:57
  • @Pacerier We used to load Struts 1 in Tomcat as a servlet. The Struts Controller servlet would send different requests to different threads the same way a web server would, just at the servlet level instead of the container level. I imagine the overhead was minimal. What tends to be slowest is the database calls. 2nd slowest, building the HTML and returning it to the client. At the time it was popular to use a separate server for static content for speed, so it worked out. – GlenPeterson Aug 23 at 15:31
4

I would suggest learning about basic JSP and Servlets as it will help you grasp the concepts that are simplified in Spring. Since you have experience with PHP-based CGIs, most of JSP/Servlets will just different ways of doing things you are familiar with so it should go fairly quickly. The hardest thing you may find will be picking up the unique idioms in the java world.

As far as Hibernate goes, I'll agree with MebAlone and say learn it if you need to, but if it's already set up you can do 90% of what you'll need to by just cribbing what others have done.

2

It sounds like you want to learn server side web development with java. There are a number of frameworks. Spring MVC is in fact the most popular, it is mature, very full-featured, and a good framework to know. Spring MVC and other java web frameworks abstract the java servlet API from the programmer - so technically you don't need to know it. But I would suggest learning the basics - particularly the key classes. A day of study should get you there.

As for JSP, if you know PHP you already understand the essentials. JSP is java's version of server-side scripting.

Hibernate is an implementation (the most popular) of JPA, which is the java spec for persisting objects to RDBMS. With the explosion in popularity of NOSQL db's (Hadoop, Mongo, etc), Hibernate is much less of a 'must know' than it was even 18 months ago. Personally I learn storage technologies on a need-to-know basis because there's a lot of them, and you lose what you don't use.

  • What book could you suggest for Spring MVC? what is the difference bet Spring and Spring MVC? – KyelJmD Sep 7 '12 at 0:27
  • Spring is a java technology stack that includes a wide variety of projects. Spring MVC is the server side web framework. Spring's online documentation and sample applications are the best way to learn Spring MVC. – MebAlone Sep 7 '12 at 4:34
2

Short answer: no, you don't need to learn Servlets and JSPs as a pre-requisite for Spring MVC and many other Java web frameworks.

Let's get Hibernate out of the picture first. It's a persistence layer framework and it doesn't have anything to do with Servlets and JSPs.

Servlet API is the lowest level for almost all Java web frameworks. Even JSPs are compiled to servlets.

Spring MVC is a layer on top of Servlet API with lots of helpful extensions and integration with Spring Core. You can use JSPs as a rendering mechanism for Spring MVC. Spring MVC tutorial will take you all the way from the ground up to create web apps. As you go along you will learn about JSPs, and you will be well equipped to understand Servlet API as well.

-1

it seems like you are stuck on an issue that I faced recently. My goal was to learn server-side development with Java. So, I started off with servlets, understood their working and wrote some simple programs to run on the TomCat server. TomCat, is a pre-requisite. You should definitely be familiar with TomCat if you wanna proceed further. As far as struts2 or Spring are concerned, struts2 and spring are frameworks built on servlets, which makes having a deep understanding of servlets essential if you want to be strong at the basics. I started off with Java Brains tutorials. For a beginner, these tutorials are amazing. Some works by Jakob Jenkov on his blog are really amazing too. Struts2 and Spring do become simpler when you know servlets. As far as hibernate is concerned, I suggest you to start off with being really familiar with JDBC. Go stepwise, servlets , struts , JDBC , Spring , Hibernate . Hope my answer helps :) .

  • this post is rather hard to read (wall of text). Would you mind editing it into a better shape? – gnat Dec 20 '15 at 16:53

Not the answer you're looking for? Browse other questions tagged or ask your own question.