Pages Navigation Menu

Coding is much easier than you think

Why use JSP when we can do the same thing with servlets?

Highly Coupled Servlets

In our previous tutorial we have implemented an servlet hello world example, in which a servlet acts as both controller as well as presenter; below are the list of problem when servlet acts as both controller and presenter,

  • High cost of maintenance
  • HTML and Java exist in the same file.
  • Web Designers don’t understand java code, don’t like the java code…
  • Programmers don’t particularly like the messing with <HTML> code!!!!

In simple words ….

if( developer == javaProgrammer)
	System.out.println("Stick to Java code!");
else if( developer == webDesigner )
        System.out.println("Stick to html code!");

So its better to separate JAVA code from the HTML code. Now the Question is How to Separate ????

Java Server Pages(JSP)

Java Server Pages (JSPs) provide a way to separate the generation of dynamic content (java) from its presentation (html)

How do JSP’s Work

The work flow of jsp is depicted pictographically below.
jsp work flow
In our next tutorial we shall learn to implement hello world example in servlet using JSP.

Leave a Comment

Your email address will not be published. Required fields are marked *