jakarta-cactus-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kazuhito SUGURI <suguri.kazuh...@lab.ntt.co.jp>
Subject Re: Overriding a Servlet Context Parametners
Date Thu, 30 Sep 2004 05:30:16 GMT

In article <B5866F61D228734592115BA77F72971401BCFB7E@USAWVMS08-BK.opbu.xerox.com>,
Tue, 28 Sep 2004 17:33:23 -0700,
"Brehm, Robert P" <robert.p.brehm@office.xerox.com> wrote: 
robert> public void beginLoginJSP(WebRequest response) throws Exception {
robert> 	sc = (AbstractServletContextWrapper) this.config.getServletContext();
robert> 	String hostname = (String) sc.getInitParameter("serverhost");
robert> 	int port = Integer.parseInt((String) sc.getInitParameter("serverport"));
robert> 	sc.setInitParameter("serverhost","localhost");
robert> 	sc.setInitParameter("serverport","7000");
robert> }//method
robert> public void testLoginJSP() throws Exception {
robert> 	sc.getRequestDispatcher("/login.jsp").forward(request,response);
robert> }//method

AbstractServletContextWrapper#setInitParameters() does not change
the corresponding init-parameter value of the original ServletContext.
So, the re-assigned values cannot be refered from other servlets,
including a servlet generated from your login.jsp.

robert> But in my login.jsp there are the following two lines:
robert> 	String serverHost = application.getInitParameter("serverhost");
robert>     	int serverPort = Integer.parseInt((String) application.getInitParameter("serverport"));

BTW, why are you using init-parameters instead of attributes?

Kazuhito SUGURI

View raw message