• Post Reply Bookmark Topic Watch Topic
  • New Topic

Initializing JSP.  RSS feed

 
Abiodun Okusolubo
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have spent unbelieveable 5-7 hours on this area, but still can't get a solution to it in head first Servlet/jsp. I need help please.



DD:

<servlet>
<servlet-name>MyTestInit</servlet-name>
<jsp-file>/TestInit.jsp</jsp-file>
<init-param>
<param-name>email</param-name>
<param-value>somethingtobepassed</param-value>
</init-param>
</servlet>


JSP code:

<%!
public String method(){
ServletConfig sConfig = getServletConfig().getInitParameter("email");

return sConfig;
}
%>


<%= method() %>

When method() is call, it is always returning null. I am absolutely tired of this jsp. Please, I need someone to get me out of this.

Thanks.
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your method must return a String, not a ServletConfig. This is what you need:
 
Abiodun Okusolubo
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, that line was a mistake, I typed the notes in anger.

Actually it is:

String emailAddr = getServletConfig().getInitParameter("email");
return emailAddr;
 
Abiodun Okusolubo
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have found my mistake, I guess I've been too stressed for the weekend.
Thank you for reply me Mr Chung-Wee. I hope to have your qualifications one day. Cheers.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66208
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have found my mistake,


Would you care to share it so that others with similar problems might benefit?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!