sachin srivastava
sachin srivastava

Reputation: 163

why sometimes jsp is used instead of html for user interface?

I have a project that I am working on Spring MVC. The project uses jsp instead of html in my view for the front end UI. Can you please tell me why jsp is being used and not HTML. Is there any special purpose for using .jsp files instead of .html in Spring MVC. Can't I use html and Javascript to achieve the same functionality?
I understand this is a basic question but I dont have any experience in web development, I have just started working in a company and they want me to work on this. I have tried looking for comparisons, but there are a lot of comparison between jsp and servlets online but I cant find anything which tells why jsp is used instead of HTML pages. This might be very obvious to you but its not to me. Any hints, links, description is appreciated.

Upvotes: 0

Views: 3393

Answers (1)

Adesh Kumar
Adesh Kumar

Reputation: 109

From my experience below are the reason of using jsp or more in general a template language for rendering view.

  • HTML can not read request data as it actually don't know what is request / session data and it has nothing to do with it actually. On the other hand, jsp knows request, response, session etc.

  • when you need to generate your content dynamically you may use loops and other logical stuff available but how will you do that in html? Your answer could be using javascript but it would be more problematic.

  • HTML is statically typed and is parsed at browser i.e. client side and hence would be evaluated at client side which exposes your page and would allow client to do several manipulations. But JSPs are server side and hence are more secure and safe as client can only access html in last.

  • Last but not least Java knows JSP but not html and hence for developers using JSP is better as they easily do good manipulations which a UI dev can't do .

Hope it helps!

Upvotes: 3

Related Questions