• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

get init parameter

 
Diogo Gonzaga
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've been declared an init-parameter on DD for a jsp page, but it does not work. It is in the following:

<servlet>
<jsp-file>/pages/teste_param.jsp</jsp-file>

<init-param>
<param-name>teste</param-name>
<param-value>ola mundo</param-value>
</init-param>
</servlet>

in jsp:

<%!String s = null;
public void jspInit() {
ServletConfig sConfig = getServletConfig();

String s = sConfig.getInitParameter("teste");

}
%>

<%
out.print(s);
%>

what's wrong?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"DIOGO GONZAGA",
Welcome to the Ranch. Could you edit your profile and change your name so that it's not made of capital letters only ? -> Diogo Gonzaga
Thank you
 
raja ram
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

In DD i think you are missing <servlet-name> element or typo error here in the
post. When you are calling the Jsp dont call it directly what i mean to say. In DD you might have given the url-pattern,Call it in that way so that control goes through DD and not directly.

Thanks
[ November 04, 2008: Message edited by: raja ram ]
 
Praveen Kumar
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should define corresponding <servlet-mapping> element and define <url-pattern> and access the jsp with that URL and see .

That time you should get the init parameters.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic