Problem with accessing init parameters from JSP file

Hi,

I have my init parameters and Jsp configured in web.xml

<servlet>

<servlet-name>TestJsp</servlet-name>

<jsp-file>/Test.jsp</jsp-file>

<init-param>

<param-name>username</param-name>

<param-value>Balboa</param-value>

</init-param>

</servlet>

How do I access 'username' field from JSP file.

Kindly help.

Thanks.

[430 byte] By [beejuma] at [2007-11-27 11:41:32]
# 1

you can do this in the jsp

<%=config.getInitParameter("username")%>

or do it in the jspInit method in the jsp:

<%! String userName = null;

public void jspInit() {

ServletConfig config = getServletConfig();

userName= config.getInitParameter("userName ");

}

%>

Hello <%=userName%>

yorkroada at 2007-7-29 17:38:42 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

Ya that's working fine, but the value which I am retreiving is

null

.

I tried to troubleshoot it, but i couldnt resolve the problem. Could you tell why is that happening.

Thanx

beejuma at 2007-7-29 17:38:42 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...