r/learnjava • • Jan 04 '23

Should I learn JSP, Servlets before learning Spring,Springboot?

Pretty much the title.

I tried learning JSP, Servlets on YouTube. But the videos are pretty old. Do I need to spend time learning these? Or can I directly learn Spring, Springboot. I want to be a fullstack Java + React kind of developer. Pls guide me.

41 Upvotes

28 comments sorted by

•

u/AutoModerator Jan 04 '23

Please ensure that:

  • Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions

  • You include any and all error messages in full - best also formatted as code block

  • You ask clear questions

  • You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions.

If any of the above points is not met, your post can and will be removed without further warning.

Code is to be formatted as code block (old reddit/markdown editor: empty line before the code, each code line indented by 4 spaces, new reddit: https://i.imgur.com/EJ7tqek.png) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc.

Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit.

Code blocks look like this:

public class HelloWorld {

    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
}

You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above.

If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures.

To potential helpers

Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

25

u/s0me__dude Jan 04 '23

Spring provides a higher-level abstraction that you can use effectively without knowing how it is implemented. So you can start learning spring right away.

5

u/Sabarkaro Jan 04 '23

Okay thanks. That means if required, I can visit JSP, Servlets after learning Spring as well.

17

u/RandomFuckingUser Jan 04 '23

Some say it helps you understand Spring better, but it's not necessary

4

u/Sabarkaro Jan 04 '23

Oh okay..thanks

22

u/vladadj Jan 04 '23

Spring web MVC is based on servlets. Pretty much every web framework in Java is based on servlets. So, I would strongly advise you learn it first.

You can definitely learn Spring without learning servlets first, but you will have a big gap in understanding how things work under the hood.

3

u/Sabarkaro Jan 04 '23

Oh thanks. I guess I'll prefer learning Servlets. I don't want to mug up things. I want to really understand them. May be I'll spend few days learning JSP, Servlets.

2

u/Kapparzo Jan 04 '23

I wish I could manage it in a few days lol

1

u/Geekfest65 Jan 05 '23

If you learn servlets first , then you can convert you servlet into a spring controller by just implementing the Controller interface. You implement one method, handleRequest. Done configuration is necessary in your web.xml and some spring configuration files.

After that look into SpringMVC

1

u/IamOkei Jan 04 '23

Where to learn Servlet?

9

u/PuzzledByThat Jan 04 '23

I used this series as a refresher on JSP and Servlets. She does a good job going into all the little details. It’s pretty recent so it has the new Jakarta libraries versus the older javax libraries. Look up Miss Xing : Jakarta Servlet & JSP on YouTube. Here’s the link if it’s allowed: https://youtube.com/playlist?list=PLGTrAf5-F1YIX68uT78FFtA3R3zajVFJz

The JSP part isn’t as important with Spring but the servlet part is.

1

u/Sabarkaro Jan 04 '23

Thank you. Will look into it.

9

u/javlck_stripe Jan 04 '23

Go to learn spring first and then springboot. No need to learn jsp

4

u/Sabarkaro Jan 04 '23

Thank you!.

12

u/garagesaleboi Jan 04 '23

I learned Spring, spring web MVC, security, rest, hibernate, jpa etc from scratch before going over to spring boot and found that super helpful since it helped strengthened my fundamentals.

Tried going straight to springboot a few months ago and had a hard time understanding it.

Came from a react background too, personally I just sped through/skipped alot of the JSP stuff since i knw how the client server interaction was going to be.

Udemy has some pretty good courses that i found are way more structured than youtube tutorials (unfortunately...)

12

u/PizzaHuttDelivery Jan 04 '23 edited Jan 04 '23

There are two possible approaches: top-down and bottom-up. Top-down where you first start with spring boot and learn to work with its magic by focusing on its capabilities and how it solves different problems for you. Grandually, you will scratch beyond its surface to discover the servlets, filters, which are not so deep within the framework itself. You get to see the big picture first, then you go deeper.

Alternatively you can go bottom-up, by doing a simple servlet application deployed in tomcat. But you will have to deal with a lot of low level stuff in this case: how do you serialize/deserialize the HttpSevletRequest/HttpServletResponse? You need to add Jackson or Gson manually. How do you setup your project structure so that tomcat will accept your WAR file and many many tiny details. That is not mentioning the fact that you will have to come up with some kind of global exception handling mechanism (which is already present in SpringWeb's DispatherServlet).

My suggestion is go first top-down to have a general understading of the whole spectrum of possibilities. Then try to regress back to servlets without using spring, Then gradually add spring framework, but without spring boot, so that you have to configure all those important beans. By the time you will be ready to finally upgrade to SpringBoot and remove all your manual configuration, you will know servlets and Spring ecosystem bettern then a person that only learned spring by top-down approach.

I am a curator of a Java/Spring Internship program at my company and this is my strategy how I train juniors to become really strong at having a good control over our spring applications.

Oh and drop JSP. Its old. You dont need it.

1

u/SushNag_22 Jan 05 '23

This is a great approach. Thank you for sharing it!

1

u/AngeFreshTech Jan 05 '23

Any link of a tutorial or book to learn servlet that you advise the interns at your company ?

1

u/PizzaHuttDelivery Jan 05 '23

Honestly I never really thought of that. You see, Servlets are like JDBC, just a collection of classes and interfaces, you study their API and a few minor details how to make the Tomcat recognize them (either web.xml or the annotations added to servlets 3.0). Using servlets at its essence it's just like using some random java class.

2

u/knoam Jan 04 '23

JSP is for server-side rendered apps. React is for client side rendered apps. You can technically use both together, but for the most part they are alternatives to one another.

2

u/2Bits4Byte Jan 05 '23

Guess depends where you want to go

Spring, spring boot, spring webflux

Some of the modules that spring offers we moved away from. But you should know how service discovery works and load balancing, eureka with ribbon is a good starting point.

Also learn about non-blocking, reactive programing and events (kafka isn't bad).

You can use Karate to help right bdd tests for restful services.

1

u/brunocborges Jan 04 '23

You should be able to learn enough to have a good grasp of how things work, within 2 or 3 days.

Then, never look back.

1

u/Striking_Insurance16 Jan 05 '23

no, you can learn spring boot and spring framework directly

0

u/AutoModerator Jan 04 '23

It seems that you are looking for resources for learning Java.

In our sidebar ("About" on mobile), we have a section "Free Tutorials" where we list the most commonly recommended courses.

To make it easier for you, the recommendations are posted right here:

Also, don't forget to look at:

If you are looking for learning resources for Data Structures and Algorithms, look into:

"Algorithms" by Robert Sedgewick and Kevin Wayne - Princeton University

Your post remains visible. There is nothing you need to do.

I am a bot and this message was triggered by keywords like "learn", "learning", "course" in the title of your post.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

4

u/[deleted] Jan 04 '23

[removed] — view removed comment

8

u/nekokattt Jan 04 '23 edited Jan 04 '23

this is false, reactive web applications in Java do not use servlets at all... likewise a web framework does not need to use servlets either. Servlets are just a convinience API for enabling multiple implementations of Web server to attach applications in an implementation agnostic way.

Many do use servlets but saying that all do isn't correct and could be potentially misleading to new developers as it could imply servlets are some kind of mandatory nexus for using HTTP in the JVM (which is definately not the case)