| Author |
Configuring JSP init parameters
|
Abhishek Jain
Greenhorn
Joined: Sep 02, 2005
Posts: 26
|
|
Hi All I am screwed with a problem where I wana to read init-param from jsp JSP LOCATION :- /webapps/JSPCounter/JSPCounter.jsp Web.xml Contents :- <servlet> <servlet-name>JSPCounter</servlet-name> <jsp-file>/JSPCounter.jsp</jsp-file> <init-param> <param-name>myID</param-name> <param-value>abhi_svits@yahoo.co.in</param-value> </init-param> </servlet> Overriden init method :- public void jspInit(){ ServletConfig scg=getServletConfig(); String myID=scg.getInitParameter("myID"); System.out.println(myID); ServletContext scx=getServletContext(); scx.setAttribute("myID",myID); } when i am using this code its giving me null value ??? Regards Abhishek
|
SCJP <br />SCWCD <br />SCBCD <br />SCEA Preparing
|
 |
Eddy Lee Sin Ti
Ranch Hand
Joined: Oct 06, 2005
Posts: 135
|
|
You can try to define the servlet mapping for this servlet. In your case, you can define the mapping as follows: Hopefully it works.
|
SCJP, SCWCD, SCJWS, IBM 700,IBM 701, IBM 704, IBM 705, CA Clarity Technical<br /> <br /><a href="http://eddyleesinti.blogspot.com" target="_blank" rel="nofollow">http://eddyleesinti.blogspot.com</a>
|
 |
Abhishek Jain
Greenhorn
Joined: Sep 02, 2005
Posts: 26
|
|
Hi Eddy Still its not working Regards Abhishek
|
 |
Raghu Shree
Ranch Hand
Joined: Mar 18, 2005
Posts: 143
|
|
Hi Abhishek, Your code is perfectly legal. No error in your code. I think there is some configuration problem. Check your web.xml file for servlet configuration and servlet mapping. If you would change in your web.xml just restart the server and try it in browser. Hope it will helps you. If you have same problem again give me your web.xml file.
|
Raghu J<br />SCJP 1.4<br /> <br />The Wind and waters are always<br />on the side of the ablest navigators.<br /><a href="http://groups.yahoo.com/group/scjp_share" target="_blank" rel="nofollow">SCJP Group</a><br /><a href="http://groups.yahoo.com/group/JavaBeat_SCWCD" target="_blank" rel="nofollow">SCWCD Group</a>
|
 |
Abhishek Jain
Greenhorn
Joined: Sep 02, 2005
Posts: 26
|
|
Hi Raghu, FYI, location :- webapps\JspCounter\web.xml <?xml version="1.0" encoding="ISO-8859-1"?> <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4"> <servlet> <servlet-name>JSPCounter</servlet-name> <jsp-file>/JSPCounter.jsp</jsp-file> <init-param> <param-name>myID</param-name> <param-value>abhi_svits@yahoo.co.in</param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>JSPCounter</servlet-name> <url-pattern>*.jsp</url-pattern> </servlet-mapping> </web-app> Regards Abhi
|
 |
Raghu Shree
Ranch Hand
Joined: Mar 18, 2005
Posts: 143
|
|
Hi Abishek, Could you please verify the web.xml is available in webapps/JspCounter/WEB-INF/web.xml. [ October 18, 2005: Message edited by: Raghu Shree ]
|
 |
Abhishek Jain
Greenhorn
Joined: Sep 02, 2005
Posts: 26
|
|
Hi Raghu I was so stupid yaar ........ Yup finally it worked CREDIT TO U ONLY can I have ur mail ID if u like... It would be g8 having a friend like U Thnkx a LOT Regards Abhishek
|
 |
Raghu Shree
Ranch Hand
Joined: Mar 18, 2005
Posts: 143
|
|
Hi Abishek, Sure. jayraghu04@gmail.com. This is my mail Id.
|
 |
 |
|
|
subject: Configuring JSP init parameters
|
|
|