• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to config jsp in web.xml?

 
Li Shangqiang
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i've known how to do this to a servlet, but now I want to config a jsp file in web.xml and read the config int jsp. Who can tell me?
 
Jolly Jumper
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are no difference as doing in servlet. You just need to create a jsp library which imports DOM Parser and other necessary classes, then migrate code from servlet to jsp lib.
Include this lib anywhere you want to get xml data in jsp file. Use methods declared in lib to parse this xml file result in a DOM object. Use other method to get data from DOM.
 
Simon Brown
sharp shooter, and author
Ranch Hand
Posts: 1913
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alternatively, you could use initialization parameters in the web.xml file and use the ServletContext to retrieve them from your JSP.
Hope that helps...
Simon
------------------
Simon Brown
Co-author of Professional JSP 2nd Edition
 
vivek sivakumar
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi if u need more details about web.xml then tell me i can send u a white paper which my firend has written about web.xml!!!
 
Li Shangqiang
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please give me a sample web.xml file. I've know config servlet like this:
<servlet>
<servlet-name>myservlet</servlet-name>
<servlet-class>MyServletClass</servlet-class>
<init-param>
<param-name>Para1</param-name>
<param-value>Value1</param-value>
</init-param>
</servlet>
But if i want to config a jsp file, what's the result? And How can i get the init parameter from the web.xml file? If you have a sample file, it will be very easy to understand.
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here I quote from the JSP 1.1 specification:
A Web component is either a Servlet or a JSP page. A web component may use the services of its container. The servlet element in a web.xml deployment descriptor is used to
describe both types of web components; note that most JSP page components are defined implicitly in the deployment descriptor through the use of an implicit .jsp extension mapping.
What this means is that you usually don't have to do anything in a web.xml to use JSP's...
Kyle
------------------
Kyle Brown,
Author of Enterprise Java (tm) Programming with IBM Websphere
See my homepage at http://members.aol.com/kgb1001001 for other WebSphere information.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!