How do I map a JSP using web.xml and RequestDispatcher?

Abhinav Srivastava

It is not mandatory for JSPs to be registered in the web.xml but it is sometimes done; the <servlet-class> tag being replaced by the <jsp-file> tag (and others remaining the same).

e.g <jsp-file>/index.jsp</jsp-file>

And thus you can give a JSP an alias.

Now when you want to forward to a servlet that doesn't have a url-mapping in the web.xml, you use getNamedDispathcer(servlet-name) else it should be the url-pattern when you are using getRequestDispatcher(path).

This is what I have understood of it. The more hazy part is that even JSPs are compiled into servlets at runtime. But these servlets are accessible without specifying any url-pattern.

0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact