Skip to main content

Featured

Game Development Tutorials In Android

Game Development Tutorials In Android Hi Guys,                 We are shortly started Game Development Tutorials in Android Studio. So everyone supports me and share this blogs to your friends. Guys, At this time everyone is freely available to source code and we are provide a video for step by step game developments. you are learn free and feel free to support us. Guys, if you have any question to me, so feel free to comment us. I will try to answer all the question as long as possible.                                                     Thank's                                                                          ...

Example of ServletContext to get all the initialization parameters

Example of ServletContext to get all the initialization parameters

We are getting all the initialization parameter from the web.xml file. For getting all the parameters, we have used the getInitParameterNames() method in the servlet class.

DemoServlet.java
1.     import java.io.*;  
2.     import javax.servlet.*;  
3.     import javax.servlet.http.*;  
4.       
5.       
6.     public class DemoServlet extends HttpServlet{  
7.     public void doGet(HttpServletRequest req,HttpServletResponse res)  
8.     throws ServletException,IOException  
9.     {  
10.   res.setContentType("text/html");  
11.   PrintWriter out=res.getWriter();  
12.     
13.   ServletContext context=getServletContext();  
14.   Enumeration<String> e=context.getInitParameterNames();  
15.         
16.   String str="";  
17.   while(e.hasMoreElements()){  
18.       str=e.nextElement();  
19.       out.print("<br> "+context.getInitParameter(str));  
20.   }  
21.   }}  
web.xml
1.     <web-app>  
2.       
3.     <servlet>  
4.     <servlet-name>bschandel</servlet-name>  
5.     <servlet-class>DemoServlet</servlet-class>  
6.     </servlet>  
7.       
8.     <context-param>  
9.     <param-name>dname</param-name>  
10.   <param-value>sun.jdbc.odbc.JdbcOdbcDriver</param-value>  
11.   </context-param>  
12.     
13.   <context-param>  
14.   <param-name>username</param-name>  
15.   <param-value>system</param-value>  
16.   </context-param>  
17.     
18.   <context-param>  
19.   <param-name>password</param-name>  
20.   <param-value>oracle</param-value>  
21.   </context-param>  
22.     
23.   <servlet-mapping>  
24.   <servlet-name>bschandel</servlet-name>  
25.   <url-pattern>/context</url-pattern>  
26.   </servlet-mapping>  
27.     
28.   </web-app>  

If this information is important to you , and you want to , I will continue writing some more details of programming language, so click on the advertising, available on this page. This is motivate me for writing some more blogs.

Comments