JSP and servlets before Spring MVC [closed] - java

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
Hello I want to know if I can start learning Spring MVC even if I don't have any knowledge about JSP and Servlets, I used to program before in php and codeigniter. and now I want to start with java and I've heard that spring mvc is the most used framework out there.

Yes, you can start learning Spring MVC.
The problem(s) will begin when you need to debug Things That Go Wrong, because you won't have the background knowledge of the components Spring is built upon.
That's not necessarily a bad thing, but it will make some things take longer than they might otherwise. For the most part, you can learn JSP as you go along. You don't need to learn about servlets specifically, but Spring MVC relies on the Servlet Specification, which talks about things like Java EE scoping (e.g., request, session, etc.), JSPs, filters, and so on.

The "V" in "MVC" stands for "View". The Views in Spring MVC are all generally built on top of JSP's, which are in turn built on Servlets, so you will probably have to learn them at some point. That being said, much of the Spring MVC tutorial material out there starts at the beginning, so you can learn the entire technology stack as you go, although you may want to have a JSP guide or reference handy, as the Spring MVC material won't get into the gory details of JSP syntax.

Spring is used a lot but so is Apache Struts and a dozen of other frameworks so you should also consider whether you want to stick to a specific framework.
From my experience refactoring Spring code to something else is quite difficult so once you go with Spring you must stay with it for a long time especially if your project is complex.
From my experience learning JSP and some JSF would be more than enough for most projects and you would have more time to consider frameworks.
I used Apache Struts a lot and now I got back to using only standard Java tools so JSP, JSF and JPA.

Related

Switching from ASP.NET to Java EE for a large web project [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I'm an ASP.NET developer, I'm happy with ASP.NET MVC and Entity Framework...
I want to use Java EE in a new web project, but there is a lot of specifications and frameworks (jsf, ejb, hibernate ...),
I'm looking for the best combination of Java EE specification tu use for a big Web Project (I must use HTML5, Javascript, JQuery, Javascript Framework like Telerik Kendo UI, Json, Webservices ...) and I love MVC so I'm looking for the MVC support in Java EE
For now, I decided the deployment server: Debian + Glassfish
I don't care about learning curve, but I do care about stability and performance
You can use Spring Web MVC for following reasons.
Active Community
Great Documentation
Ease of learning
MVC Architecture Supported
Used in the Industry
You probably wanna go with Spring, MVC being only one of the reasons. I can't tell whether it is the best in the Java landscape (maybe it is, I love it), but given how widely used it is you will most likely find someone able to help whenever you run into something you can't figure out by yourself.
Same applies for Maven when it comes to dependency management. Another viable alternative would be Gradle, but Maven is probably used more widely.
I would also suggest keep your project "Mavenized", i.e. buildable without IDE. That does not mean don't use IDE of course, just make sure it is buildable right after pulling the project from the repository, without starting your IDE.
Just yesterday I read this great article that might help you adopt some good habits right from the start: http://www.jamesward.com/2014/12/03/java-doesnt-suck-youre-just-using-it-wrong
In fact there are many amazing Java EE tools and frameworks, I think the best combination will be using:
Spring framework, Hibernate ORM and JSF (precisely Primefaces) because they all have highly active communities, Good documentation with great tutorials.
I have very good experience with Tapestry5 and for the model layer JDBC templates or JPA(Hibernate) which is an ORM tool like Entity Framework.
Tapestry5 is a component based framework and it works nice. Great support for AJAX. They have a quite big community and a lot of components.
You can also use JSF (check primefaces, richfaces) + Spring(or CDI) + model layer
If you want something for rapid development use Vaadin or Liferay.
You can also go with Spring MVC which is also a good choice.
For testing use Selenium tests which are just great.

Similar web framework to Grails but that uses Java not Groovy? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
Are there any Java Web Frameworks that are very similar to Grails but use pure Java instead of Groovy?
I really like the look of Grails, but at this moment want to focus solely on improving my Java skills, so do not want to use Groovy.
I have looked at Spring MVC and Play Framework but I only plan to develop quite simple personal applications, which is why Grails appealed to me as these seem quite heavyweight.
Play, Spring Roo and Spring Boot are the closest Java frameworks I know of. I don't like Spring Roo's code-generation approach, don't know much about Play, so my personal preference would be Spring Boot. It seems to be under very active development at the moment and you can use some of the nicest parts of Grails in a Spring Boot app, e.g. GSP, GORM.
I don't know about "similar to Grails," but the most basic Java web framework is the Servlets and JSP spec from Oracle. If you want to get started with Java, grab that and a copy of Netbeans and you can get started.
You can use pure java if you still wish to utilize the Grails framework. Since Groovy is based on java, you cam use both at the same time too if you like.
Other than this, you will probably have to look into pure Servlets combined with jsp's to achieve the same thing, but it won't be as straightforward as Grails.
Take a look at Spring Roo
This will allow you to generate simple Java web applications that use a database which you can then modify.

Is JSF/JSP the only choice if I use the Java EE to develop my site? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
I am studying Java EE technology. I noticed that JSF is an available choice for developing web application. But is it the only choice if I wanna use Java EE tech?
You have numerous Choices when it comes to choosing Web Application Frameworks, depending upon your choice you select one.
You can go for no framework too, but it would be like ending up with complex designs that even yourself won't be able to understand later.
JSF, Netty, Seam, Sitemesh, Spark, Spring MVC, Stripes, Struts, VRaptor, Wicket are some of the examples you can go for.
With JSF, you have navigational framework, MVC framework and RichFaces/IceFaces for front-end. With others, you have navigation and mvc too, and you can use jQuery for front-end.
When it comes to using Databases, transactions, etc. You will have to make another choice between persistence implementations i.e. JPA, EJB3.0 JPA Implementation, Hibernate, Spring with Hibernate and MVC and IoC.
so.. long story short, you need to read.
JSF is only one of the Front-End solutions. There are too many to enumerate.
There are differences between they, advantages and disadvantages.
Other Javascript based UI is GWT.
You can have non Javascript based ones: JSP or even just servlet for a "Hello word"
You can use frameworks which will have the MVC pattern embedded: Struts, Spring.
For start learning: I would choose a framework free implementation - to learn what is implemented later in different frameworks. Just a plain JSP pages written manually.
Later on production, bigger J2EE, which will require more team members, higher speed of development, you can choose a framework, which the project needs and most of developers know.

Raw Servlet vs. Spring MVC [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
What are the reasons you should build your web application with raw Java Servlets or by using Spring MVC (or any other frameworks)?
Are there exceptions when you should avoid Spring MVC, what are the advantages of doing it with Raw Servlets?
If you're building a really quick and dirty demo that you have no intention of extending later, spring can result in a lot of additional configuration issues (not really if you've done it before, but I always end up fighting with it one way or another), so that might be a time to consider just using plain old servlets. Generally though, anything beyond just a super fast and dirty demo, using some form of MVC framework is going to make life in the future a lot easier and is also in line with best practices. Spring makes things super easy, just have to spend some time on the front end configuring everything.
I should note, there's nothing you can do with java servlets that you can't do with Spring. The big difference is setup time.
Edit: It's worth noting that when I posted this answer, I was unaware of Spring Boot that is actually quite easy to get up an running using either an embedded web server or a more conventional web container. Here's a link to a quick start example: http://projects.spring.io/spring-boot/#quick-start
Servlet technology is used for more generic server side extension for request-response paradigm.
And Spring just uses it for the Web application over HTTP.
And some quote from here:http://www.reddit.com/r/java/comments/29f3ul/why_is_spring_mvc_better_than_servlets_jsp/
Servlets are based upon a low-level API for handling requests and
responses. Web frameworks like Spring MVC are designed to make
building web applications, which handle HTTP requests and responses,
easier. Most Java web frameworks, including Spring MVC, use servlets
behind the scenes.
You CAN use servlets to write a web application, but you'll have to
handle all of the details manually. You'll get very little help with
typical web stuff like validation, REST, request/response body for
JSON, form binding, etc. You will end up writing lot of utility code
to support your web application.
Web frameworks, on the other hand, are designed to make all of this
stuff simple. With Spring MVC, you aren't bothered with manually
handling the request and response even though you can still get access
to them if you need to. Want to return JSON in Spring MVC? Just add a
#ResponseBody annotation and Spring will append it. Want RESTful URLs?
Easy. Input validation? Piece of cake. Want to bind form data to an
object? Simple. With servlets, you'd have to do all of this stuff
manually.
Using raw servlets can be a good learning experience though. It really
helps to clarify how web frameworks make life easy for you!
I have developed projects both with raw servlet and web app framework.
Framework gives you everything, only you need to is to setup and config the env, coding is much more easier. The result is that you will know nothing about web dev.
However, code with raw api and servlet gives you chance to gain experience and be a programmer.
I don't use Spring a lot. But I don't see how would it have big impact on the performance. MVC's can help, but they can create a mess and extra work and frustration.
The old good way is good enough for most projects implemented by one programmer. MVC's could help when there are more than one developer.
I would use a plain servlet/jsp for most projects. If I need reusable components, I use wicket. Servlets goes with JSPs/freemarker/velocity or other template engine for presentation.
If you follow a naming pattern for your Servlets/JSP, I don't think you need Spring MVC.
I find that, with the addition of Spring version 3+, it becomes much more easier to bootstrap a Spring Web application with all the basics. The advantage of Spring MVC is that once you've bootstrapped the application context and the database connection, it becomes incredibly easy to create new controllers and it follows a much more logic architecture that newer developers may actually find easier as they get more familiar with it.
In fact, at my previous place of work, we were in the process of building a Java Servlet Web application, but we found that we had to create our own architecture or spine of the application and that is actually more work. Spring can take care of that which means that developers can get on with the actually application logic instead of worrying about the architecture too much.

What are the factors i should consider to select any MVC Framework [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I have worked on struts 1.2 and DWR as front end MVC framework.Now i have two projects to develop one is simple web application and another is complex.Which one i should select from most prevalent MVC Framework Spring mvc, Struts 2, DWR,JSF and brief reason to select any of the MVC . Most of the team knows all the frameworks. What are the factors i should consider to select any Framework.
I would consider what is the scope of my project, if I am anticipating complex system with lots and lots of various implementations, then I would go for Spring, for moderately complex system I would go for JSF.
One also need to consider if the primary designer leaves the team would other team members or a new comer will be able to pick particular MVC framework with ease or not (consider using well known MVC vs not-so-well-known-personal-favourite-picked-out-of-google). How mature the particular MVC framework is, are there good books written about it etc. These are just from top of my head.
Also keep in mind when there is too much of Spring (or any other ioC container) involved, there comes a time (after 8-12 months) when you are unable to debug code correctly because there are so many classes involved that you just keep tracking which class goes to which spring context files etc.
Finally, as one of my mentors used to say, don't solve the world problems (by using lots of design patterns), solve the problem at hand. :-)

Categories

Resources