can anybody please help me!!
Dear Friends, I have written a simple servlet which reads a init parameter from the web.xml file and displays on the browser. I'm a beginner and trying to learn simple servlets, I have reached where I can read some init params from the web.xml file and displays on the browser, but all the simple servlets are working without any hassle, but reading init parameter returns null in the servlet, because I triend to print that on to the console, but it returns null, please help me, awaiting a reply, regards Raasi web.xml looks like this ?xml version=1.0 encoding=ISO-8859-1? !-- Copyright 2004 The Apache Software Foundation Licensed under the Apache License, Version 2.0 (the License); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -- 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 display-nameWelcome to Tomcat/display-name description Welcome to Tomcat /description !-- JSPC servlet mappings start -- servlet servlet-nameorg.apache.jsp.index_jsp/servlet-name servlet-classorg.apache.jsp.index_jsp/servlet-class /servlet servlet-mapping servlet-nameorg.apache.jsp.index_jsp/servlet-name url-pattern/index.jsp/url-pattern /servlet-mapping servlet servlet-nameHelloServlet/servlet-name servlet-classHelloServlet/servlet-class /servlet servlet-mapping servlet-nameHelloServlet/servlet-name url-pattern/HelloServlet/url-pattern /servlet-mapping servlet servlet-nameInternationalizedHelloWorld/servlet-name servlet-classcom.jspbook.InternationalizedHelloWorld/servlet-class init-param param-namegreeting/param-name param-valueKisahairetu/param-value /init-param /servlet servlet-mapping servlet-nameInternationalizedHelloWorld/servlet-name url-pattern/InternationalizedHelloWorld/url-pattern /servlet-mapping !-- JSPC servlet mappings end -- /web-app __ Do you Yahoo!? Yahoo! Mail - Helps protect you from nasty viruses. http://promotions.yahoo.com/new_mail - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: can anybody please help me!!
Hi, Are you using init() method of the servlet for fetching init parameters like this? String str = getServletConfig().getInitParameter(param1); Rgrds, Hardik --- Raasi Potluri [EMAIL PROTECTED] wrote: Dear Friends, I have written a simple servlet which reads a init parameter from the web.xml file and displays on the browser. I'm a beginner and trying to learn simple servlets, I have reached where I can read some init params from the web.xml file and displays on the browser, but all the simple servlets are working without any hassle, but reading init parameter returns null in the servlet, because I triend to print that on to the console, but it returns null, please help me, awaiting a reply, regards Raasi web.xml looks like this ?xml version=1.0 encoding=ISO-8859-1? !-- Copyright 2004 The Apache Software Foundation Licensed under the Apache License, Version 2.0 (the License); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -- 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 display-nameWelcome to Tomcat/display-name description Welcome to Tomcat /description !-- JSPC servlet mappings start -- servlet servlet-nameorg.apache.jsp.index_jsp/servlet-name servlet-classorg.apache.jsp.index_jsp/servlet-class /servlet servlet-mapping servlet-nameorg.apache.jsp.index_jsp/servlet-name url-pattern/index.jsp/url-pattern /servlet-mapping servlet servlet-nameHelloServlet/servlet-name servlet-classHelloServlet/servlet-class /servlet servlet-mapping servlet-nameHelloServlet/servlet-name url-pattern/HelloServlet/url-pattern /servlet-mapping servlet servlet-nameInternationalizedHelloWorld/servlet-name servlet-classcom.jspbook.InternationalizedHelloWorld/servlet-class init-param param-namegreeting/param-name param-valueKisahairetu/param-value /init-param /servlet servlet-mapping servlet-nameInternationalizedHelloWorld/servlet-name url-pattern/InternationalizedHelloWorld/url-pattern /servlet-mapping !-- JSPC servlet mappings end -- /web-app __ Do you Yahoo!? Yahoo! Mail - Helps protect you from nasty viruses. http://promotions.yahoo.com/new_mail - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do you Yahoo!? Yahoo! Mail - 250MB free storage. Do more. Manage less. http://info.mail.yahoo.com/mail_250 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: can anybody please help me!!
Hello Hardik, thanks for your reply, yeas, I'm using the same code as you written, thanx eversomuch, please help me out the code looks like this [code] package com.jspbook; import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class InternationalizedHelloWorld extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { response.setContentType(text/html); PrintWriter out = response.getWriter(); String greeting; greeting = getServletConfig().getInitParameter(greeting); if(greeting != null) { System.out.println(lopaliki vachav); out.println(html); out.println(head); out.println(titleShabbu Bhai/title); out.println(/head); out.println(body); out.println(h1 + greeting + /h1); out.println(/body); out.println(/html); } else { System.out.println(bayate unnav); out.println(html); out.println(head); out.println(titleShabbu Bhai/title); out.println(/head); out.println(body); out.println(h1Emiledura Dunna/h1); out.println(/body); out.println(/html); } } } [code] --- Hardik Tank [EMAIL PROTECTED] wrote: Hi, Are you using init() method of the servlet for fetching init parameters like this? String str = getServletConfig().getInitParameter(param1); Rgrds, Hardik --- Raasi Potluri [EMAIL PROTECTED] wrote: Dear Friends, I have written a simple servlet which reads a init parameter from the web.xml file and displays on the browser. I'm a beginner and trying to learn simple servlets, I have reached where I can read some init params from the web.xml file and displays on the browser, but all the simple servlets are working without any hassle, but reading init parameter returns null in the servlet, because I triend to print that on to the console, but it returns null, please help me, awaiting a reply, regards Raasi web.xml looks like this ?xml version=1.0 encoding=ISO-8859-1? !-- Copyright 2004 The Apache Software Foundation Licensed under the Apache License, Version 2.0 (the License); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -- 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 display-nameWelcome to Tomcat/display-name description Welcome to Tomcat /description !-- JSPC servlet mappings start -- servlet servlet-nameorg.apache.jsp.index_jsp/servlet-name servlet-classorg.apache.jsp.index_jsp/servlet-class /servlet servlet-mapping servlet-nameorg.apache.jsp.index_jsp/servlet-name url-pattern/index.jsp/url-pattern /servlet-mapping servlet servlet-nameHelloServlet/servlet-name servlet-classHelloServlet/servlet-class /servlet servlet-mapping servlet-nameHelloServlet/servlet-name url-pattern/HelloServlet/url-pattern /servlet-mapping servlet servlet-nameInternationalizedHelloWorld/servlet-name servlet-classcom.jspbook.InternationalizedHelloWorld/servlet-class init-param param-namegreeting/param-name param-valueKisahairetu/param-value /init-param /servlet servlet-mapping servlet-nameInternationalizedHelloWorld/servlet-name url-pattern/InternationalizedHelloWorld/url-pattern /servlet-mapping !-- JSPC servlet mappings end -- /web-app __ Do you Yahoo!? Yahoo! Mail - Helps protect you from nasty viruses. http://promotions.yahoo.com/new_mail - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do you Yahoo!? Yahoo! Mail - 250MB free storage. Do more. Manage less. http://info.mail.yahoo.com/mail_250 - To unsubscribe,
Re: can anybody please help me!!
Hi, Use init(ServletConfig config) method of servlet for init parameters. bcs, init parameters will be set only once it is initialised... so, u have to do the same in the init() method only... thanks. --- Raasi Potluri [EMAIL PROTECTED] wrote: Hello Hardik, thanks for your reply, yeas, I'm using the same code as you written, thanx eversomuch, please help me out the code looks like this [code] package com.jspbook; import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class InternationalizedHelloWorld extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { response.setContentType(text/html); PrintWriter out = response.getWriter(); String greeting; greeting = getServletConfig().getInitParameter(greeting); if(greeting != null) { System.out.println(lopaliki vachav); out.println(html); out.println(head); out.println(titleShabbu Bhai/title); out.println(/head); out.println(body); out.println(h1 + greeting + /h1); out.println(/body); out.println(/html); } else { System.out.println(bayate unnav); out.println(html); out.println(head); out.println(titleShabbu Bhai/title); out.println(/head); out.println(body); out.println(h1Emiledura Dunna/h1); out.println(/body); out.println(/html); } } } [code] --- Hardik Tank [EMAIL PROTECTED] wrote: Hi, Are you using init() method of the servlet for fetching init parameters like this? String str = getServletConfig().getInitParameter(param1); Rgrds, Hardik --- Raasi Potluri [EMAIL PROTECTED] wrote: Dear Friends, I have written a simple servlet which reads a init parameter from the web.xml file and displays on the browser. I'm a beginner and trying to learn simple servlets, I have reached where I can read some init params from the web.xml file and displays on the browser, but all the simple servlets are working without any hassle, but reading init parameter returns null in the servlet, because I triend to print that on to the console, but it returns null, please help me, awaiting a reply, regards Raasi web.xml looks like this ?xml version=1.0 encoding=ISO-8859-1? !-- Copyright 2004 The Apache Software Foundation Licensed under the Apache License, Version 2.0 (the License); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -- 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 display-nameWelcome to Tomcat/display-name description Welcome to Tomcat /description !-- JSPC servlet mappings start -- servlet servlet-nameorg.apache.jsp.index_jsp/servlet-name servlet-classorg.apache.jsp.index_jsp/servlet-class /servlet servlet-mapping servlet-nameorg.apache.jsp.index_jsp/servlet-name url-pattern/index.jsp/url-pattern /servlet-mapping servlet servlet-nameHelloServlet/servlet-name servlet-classHelloServlet/servlet-class /servlet servlet-mapping servlet-nameHelloServlet/servlet-name url-pattern/HelloServlet/url-pattern /servlet-mapping servlet servlet-nameInternationalizedHelloWorld/servlet-name servlet-classcom.jspbook.InternationalizedHelloWorld/servlet-class init-param param-namegreeting/param-name param-valueKisahairetu/param-value /init-param /servlet servlet-mapping servlet-nameInternationalizedHelloWorld/servlet-name url-pattern/InternationalizedHelloWorld/url-pattern /servlet-mapping !-- JSPC servlet mappings end -- /web-app __ Do you Yahoo!? Yahoo! Mail - Helps protect you from nasty viruses. http://promotions.yahoo.com/new_mail