r/javahelp • • Jan 25 '19

Solved I want to try java for web development.

So real quick, I know the following:

all the fundamentals and a lot of the advanced topics of java HTML to advanced level CSS to advanced level Not that great at javascript, though I can work with it.

I want to start trying to use java for backend(web dev), I have no idea where to start. Is there a 'best' framework and where should I go to learn? I prefer docs/reference sheets but videos work too.

24 Upvotes

20 comments sorted by

2

u/HBK05 Jan 25 '19

Thank you all, I am working on spring.

21

u/nutrecht Lead Software Engineer / EU / 20+ YXP Jan 25 '19

Ignore the advice by /u/jcar74; it's complete rubbish. The ecosystem has moved a lot since 2004. He is giving you the path he (and I, I've been working as a Java dev since 2002) walked, not the one you should walk.

Start with Spring: it's beginner friendly and there's zero point in learning JPS or scriptlets unless you need to do so on the job. Modern Java based web applications are generally not deployed inside containers anymore and are generally only REST end-points that are used by a JavaScript SPA frontend (in Angular or React).

Focus on Spring for now and use a templating engine like Thymeleaf (plugs right in) to create a web application. Then dive into Spring Data JDBC and Spring Security. Once you get a good grasp of all that you can go into whatever direction you want (like a REST API together with a JS front-end).

Please don't bother with JSP, .wars, scriptlets and servlets unless you run into a situation where you need to.

2

u/Faelor Former Java/Spring Developer Jan 25 '19

I will add to this with my own experience, since it involves Java web development.

Over ten years ago I did very light development work. It mostly consisted of being a "webmaster" and designer, with the occasional modification to PHP files. I wouldn't have called myself a coder, but I knew a few things. Fast forward to 2015, I decided to go back to school (computer science) at age 28 and spent a large chunk of my free time going through tutorials (written, Pluralsight, Treehouse, Udemy, etc), documents, and networking. Coupled with some school classes and my new internship, I found myself needing to learn Spring and Java EE in parallel. Eventually it was all Spring Boot, but I experienced (briefly) the gauntlet of JSP, JDBC, downloading and referencing JARs instead of using Maven/Gradle, etc. I didn't go through these technologies over a decade or two, but I got a feel for them

As a result, I can't advocate enough to pick up Spring (Boot) and start off with their default (opinionated) templating engine, Thymeleaf. Exploring Spring Data and the absolutely basics of Spring Security will give you a solid foundation. As your knowledge and experiences grow, dip into more RESTful based architecture that uses a JS frontend. Expanding your CSS skills here wouldn't be awful either, if you want to be "fullstack".

So all in all, do what u/nutrecht said! I can say it works; it is what I did. I'm now at my second full-time developer gig (not counting internships) and while I may work in the .NET space, what I learned doing modern and old Java web develop has helped tremendously. Your mileage may vary, but Java web development is doing well and desired, thanks to the Spring suite of products.

2

u/[deleted] Jan 25 '19

Thanks for pointing out the obsolescence of that list. There’s absolutely no need to know JSP and scriplets or any mumbo jumbo that’s super JAVA. Just use Spring as that’s what any modern java shop will use and also where you will prefer to work..

6

u/bvn13 Jan 25 '19

Take a look at SpringBoot.

5

u/Holothuroid Jan 25 '19

The big fish is probably Spring. The Spring Boot Getting Started series is pretty good to start.

4

u/wsppan Jan 25 '19

Seriously, ignore the jsp/servlet/war route. Use Spring with Spring boot. Dive deep and explore.

7

u/jcar74 Jan 25 '19 edited Jan 25 '19

Begginer? My 2c, perhaps not popular.

- Do ugly jsp, deploy jsp files directly to tomcat webapps/foo

- Then do scriplets <% ... %>. Play a bit.

- Then connect to a DB directly in scriptlets. jar libraries in tomcat/shared

- Retrieve and show something

- Convert to war. Research webapp structure. web-xml, meta-inf, where to put DB config. Deploy in clean tomcat.

- Move DB access code to servlets. Call servlet functions from scriplets.

- Try to delete all scriptlets form jsp, move code to servlets (research about MVC)

- Separate DB access and objects (research about DAO/DTO)

- Research maven. Delete all library jars, convert to maven.

- Replicate with Spring Boot. Use JPA.

- Research Thymeleaf. Convert JSP to templates.

- Convert to REST api

- Research React/Angular/Vue for consume REST api and do views.

- [...]

EDIT: Thank for responses. Doing webapps ( sure not in the best way ) since 2000. This is mine (spanish)... from 2004: https://rua.ua.es/dspace/bitstream/10045/3300/5/introjsp.pdf

EDIT 2: Wow, I've got a lot of criticism. I accept it. Do not get me wrong, I really hate servlets. I've just seen a lot of "stick with Velocity / Struts / Grails / GWT / Roo ... and forget the basics" in the past. For web/Java, Spring Boot is really the way today. It is a fact. Tomorrow, who knows? Vaadin? Play? microservices with Pippo, Rapidoid, Sparkjava, Ninjaframework...? The years pass faster than it seems, the frameworks die and the projects return as the ghost of Christmas past.

2

u/BramCeulemans Jan 25 '19

This is really outdated advice, really. Get started with something like Spring Boot or Jooby

3

u/WestCoastTyyppi Jan 25 '19

Great list! You’d get a good understanding of the building blocks of a Java web app if you did all this. Could also do some JSF around the Thymeleaf step.

1

u/BlooskyDante Jan 25 '19

While this would take a lot of time to start using a framework, I think it's a great idea because he'd be able to get a good understanding of smaller things, and build up from there, rather than starting with a framework and not knowing where to start learning

1

u/AwakenedToNightmare Jan 25 '19

Try to delete all scriptlets form jsp

But how do I do it? I'm at the stage where I have some utility classes and some servlets that do some stuff with input data from forms, create some variables which are then passed to the jsps. The jsps take those variables inside <%> code snippets and display them. How else is it possible for JSPs to get access to data that needs to be displayed without code inside them?

2

u/jcar74 Jan 25 '19

With expressions (<%=) and JSTL, using it just like any template engine.

1

u/AwakenedToNightmare Jan 25 '19

I'll look into it. It's a future chapter in a book I'm reading, so right now I only now of direct coding in jsps. Thanks for the elaborate comment though, it is nice to know the direction.

1

u/[deleted] Jan 25 '19 edited Jan 14 '26

hard-to-find cover aromatic makeshift cooperative office sense cagey smile weather

This post was mass deleted and anonymized with Redact

0

u/Patchouly86 Jan 25 '19

Now I'm copying you any time someone asks how to become a great web developer

1

u/nutrecht Lead Software Engineer / EU / 20+ YXP Jan 26 '19

Yeah, that's generally how shitty advice gets perpetuated by bad developers.

2

u/[deleted] Jan 25 '19

I like using Java for my backend but I’m just a hobbyist. I use Tomcat 8. It’s really easy to do things by working from the URL back. First you add it to a web.xml file, then make a .jsp file as a template and finally write a Servlet that correspondes with the URL. You should use Tomcat 9 if you can because it has better HTTP/2 support. Honestly I think it’s a lot easier to write back end code than front end.

1

u/leonj1 Jan 25 '19

Assuming you know Basic Java and object oriented programming, here’s a few libraries:

  1. Spark Java web to help you with the URL routes.

  2. Google gson library to help with serializing and deserializing json that the service receives. Use @SerializeName to make the transition easier when it comes to json property names.

Coding 3. keep objects small, say 2-3 methods ensure they only do one thing. 4. Use interfaces for objects that talk outside of the program, say db connections, or other services. 5. Elegant Objects is a book that helped me code better.

Good luck!