VijayM
VijayM

Reputation: 327

Will JSP converted as a servlet code if i use spring?

I am using JSP as a view resolver in spring-mvc. Will those pages be converted to servlets in tomcat?

If so, is the same applicable for other views like Velocity, Thymeleaf etc.? Please explain how it works.

Upvotes: 1

Views: 683

Answers (3)

Nandkumar Tekale
Nandkumar Tekale

Reputation: 16158

Will JSP converted as a servlet code if i use spring?

Yes. If you use JSP anywhere* it will be converted to Servlet.

* - For Java EE Applications which uses Servlet containers.

I don't about Velocity ,thymleaf,etc..

Upvotes: 2

Guido
Guido

Reputation: 47665

Yes, a JSP is always converted to a servlet, that is how JSP files work.

The same is not always true in other view/templates engine. For example, Velocity is a Java-based template engine, velocity templates are parsed, but it does not depend on having a servlet engine.

Regarding to Spring, it has view resolvers for a lot of different technologies, so you have a layer of abstraction and don't have to worry about how the views are internally translated to render your model.

Upvotes: 3

km1
km1

Reputation: 2443

JSP, Velocity, Freemarker etc. in respect to Spring MVC are template libraries. For example, the user make an HTTP request to a specified URL. This URL is mapped to a Spring controller. The controller will build an instance of a model and return the view and the model. Then Spring will use the view (i.e. a jsp file) and convert it to HTML using the model. The user gets the resulting HTML.

More about Spring MVC and templates here http://static.springsource.org/spring/docs/2.0.x/reference/view.html

Upvotes: 1

Related Questions