Dear Geeta
Thank you very much for helping me out.
Regards
Ammar
Geeta Ramani
<[EMAIL PROTECTED] To: [EMAIL PROTECTED]
OM> cc:
Sent by: "A mailing Subject: Re: Protocol switching
list for discussion
about Sun
Microsystem's Java
Servlet API
Technology."
<SERVLET-INTEREST@JAV
A.SUN.COM>
08/10/01 08:45 PM
Please respond to "A
mailing list for
discussion about Sun
Microsystem's Java
Servlet API
Technology."
Ammar:
Put all your init parameters in your web.xml as below:
<init-param>
<param-name>secureUri</param-name>
<param-value>https://mycompany.com/whatever</param-value>
</init-param>
Write a ContextProperties.java as below:
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class ContextProperties extends Properties{
public ContextProperties(ServletConfig config){
Enumeration props = config.getInitParameterNames();
if (props.hasMoreElements()){
while (props.hasMoreElements()){
String name = (String)props.nextElement();
String value = (String) config.getInitParameter(name);
put(name, value);
}
} else System.out.println("Props has NO elements!!!");
}//end Constructor
} //end class ContextProperties
In your servlet's init() write code as below:
public void init(ServletConfig config) throws ServletException {
super.init(config);
try {
ContextProperties props = new ContextProperties(config);
secureUri = props.getProperty("secureUri");
// get all other ini param values here....
}
catch (Exception e){
//
e.printStackTrace();
}
}//end init()
your servlet can now access "secureUri" in the normal fashion, as in
resp.sendRedirect(secureUri)
etc. You can set session vars if needed..
If this is not clear, you may want to do some reading about initialization
params. The
archives have a lot of info (as usual!). In particular, look at Craig
McClanahan's note:
http://archives.java.sun.com/cgi-bin/wa?A2=ind9906&L=servlet-interest&D=0&P=67789
Good luck!
Geeta
"Siddiqui A. Ammar" wrote:
> Hi Geeta,
> Can you explain as how can I achieve this.
> I will be greatly obliged
> Thanks
> Ammar
>
>
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html