Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

initialization parametere with servlet error

Status
Not open for further replies.

darine

Programmer
Jun 23, 2000
28
0
0
US
Hi All<br>I'm trying to set initial value in a servlet.<br>i'm using tomcat3.1,or jsdk2.<br>with Tomcat you have to create an xml file and set the name of the servlet and the name and the value of the parameter.<br>but there is a default web.xml file in web-inf.<br>do i have to just put a name for a file with extension xml and put it along with the default file(web.xml?<br>or i have to move that default file(web.xml) and put it somewhere and name my file web.xml and put it at that directory(web-inf).<br>really i do not know and that what i did,but i got just null.<br>that means something wrong and the that parameter doesn't exist.<br>here is the files:<br>&lt;?xml version=&quot;1.0&quot; encoding=&quot;ISO-8859-1&quot;?&gt;<br><br>&lt;!DOCTYPE web-app<br>&nbsp;&nbsp;&nbsp;&nbsp;PUBLIC &quot;-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&quot;<A HREF=" TARGET="_new"> is the servlet file:<br><br>import javax.servlet.*;<br>import javax.servlet.http.*;<br>import java.io.*;<br><br><br>public class initPara extends HttpServlet<br>{<br><br> private String initial;<br> public void init(ServletConfig config) throws ServletException<br> {<br> super.init(config);<br> initial=config.getInitParameter(&quot;initial&quot;);<br><br> }<br> public void doGet(HttpServletRequest req,HttpServletResponse res)<br> throws ServletException,IOException<br> {<br> res.setContentType(&quot;text/html&quot;);<br> PrintWriter out=res.getWriter();<br> out.println(initial);<br><br> }<br>}<br><br>here is my url:<br><A HREF=" TARGET="_new"> for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top