getParameter("String") returns null when passed from outputLink tag
From an outputLink tag, I am trying to forward to servlet and then forward to a different page. This is the code I have for outputLink tag.
<h:outputLink value="#facesContext.externalContext.requestContextPath}/UtilityServlet?stateId=1">
<h:outputText value="#{varescheatments.stateCode}"
styleClass="sesOutputText"></h:outputText>
</h:outputLink>
But when I try to retrieve the value index from servlet, I get it as null. I am not sure what I am doing wrong here. Does the outputLink tag sent the parameters to a servlet? I have also tried by using f:param tag inside outputLink tag
Any help is greatly appreciated
Thanks
String stateID =(String) req.getParameter("stateId");
[830 byte] By [
slata] at [2007-11-27 8:32:51]

# 1
This should work
web.xml:
<servlet>
<servlet-name>Utility Servlet</servlet-name>
<servlet-class>com.company.web.servlets.TestServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Utility Servlet</servlet-name>
<url-pattern>/UtilityServlet/*</url-pattern>
</servlet-mapping>
Servlet:
protected void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException{
System.out.println("Test: " + request.getParameter("stateId"));
}
JSF:
<h:outputLink value="#{facesContext.externalContext.requestContextPath}/UtilityServlet?stateId=TESTPARAMETER">
<h:outputText value="Click here" />
</h:outputLink>
Output:
Test: TESTPARAMETER
(You forgot an { in your sample code: value="#facesCo...)
Cheers!
Dimi
Dimia at 2007-7-12 20:28:48 >

# 2
Thanks for the reply. But it was a typo here in the forum and I corrected it tried as well. But it did not work.I had to use
<h:outputText styleClass="sesOutputText" escape="false"
value='<a href="#{facesContext.externalContext.requestContextPath}/UtilityServlet?stateId=#{varescheatments.stateEschInfId}">#{varescheatments.stateName}</a>'>
</h:outputText>
slata at 2007-7-12 20:28:48 >
