4 Replies Latest reply on Jun 17, 2009 12:24 PM by Gregory Nikle

    Accessing <f:param> parameter's value inside a Servlet

    Ambrish Singh Newbie

      Hi,
      I have a <s:link> as shown below:




      <s:link view="/user/UserDetails.xhtml" >
      <h:graphicImage value="/img/get.gif" border="0" alt="Get Details" />
      <f:param name="iUserId" value="#{user.iUserId}" />
      </s:link>







      On UserDetails.xhtml page I am accessing a Servlet.


      Now suppose , I want to access the iUserId parameter in this Servlet.


      I have tried both


      request.getParameter("iUserId");



      and


      FacesContext context = FacesContext.getCurrentInstance();
      HttpServletRequest request= (HttpServletRequest)context.getExternalContext().getRequest();
      request.getParameter("iUserId");




      But every time I am getting Null value.


      How to do it?


      Thanks


      Ambrish

        • 1. Re: Accessing <f:param> parameter's value inside a Servlet
          Ambrish Singh Newbie

          Hi Everyone,


          Is nobody here who can solve my problem ?
          Should I ask this question on JSF forums?.


          Thanks


          Ambrish

          • 2. Re: Accessing <f:param> parameter's value inside a Servlet
            Gregory Nikle Apprentice

            Hi,


            Is any reason why u use s:link for servlet? Maybe u use simple



            <a href="myApp?firstParam=#{someParam.value}&anotherParam=#{anotherParam.quantity}><img ../></a>


            and get parameters like get in your example. This should work for servlet.


            Another question.
            I never tryed, but if u use servlet, first I will try to use servlet url instead of




            /user/UserDetails.xhtml



            something like this.




            /myPage/myservlet



            from web.xml



                 <servlet>
                      <description></description>
                      <display-name>/myPage/myservlet</display-name>
                      <servlet-name>/myPage/myservlet</servlet-name>
                      <servlet-class>com.myApp.myServlet</servlet-class>
                      <load-on-startup>2</load-on-startup>
                 </servlet>
                 <servlet-mapping>
                      <servlet-name>/myPage/myservlet</servlet-name>
                      <url-pattern>/myPage/myservlet</url-pattern>
                 </servlet-mapping>














            • 3. Re: Accessing <f:param> parameter's value inside a Servlet
              Ambrish Singh Newbie

              Hi Sherkan,


              Thanks for the reply.


              Actually I have to display the Report inside the view UserDetails.xhtml.


              I am calling the Servlet in UserDetails.xhtml page but I have to set the iUserId parameter before accessing the Servlet.


              If I use <a:href> as shown below ,




              <a href="../JasperReportServlet?iUserId=#{user.iUserId}" >
              <img src="/img/send.gif" alt="GetReport" border="0"/>
              </a>





              then it is working and the iUserId parameter is accessible on Servlet.
              But my requirement is that when I click on the above link, UserDetails.xhtml page will display and before this request parameter is set.


              Is it possible ?


              Thanks


              Ambrish

              • 4. Re: Accessing <f:param> parameter's value inside a Servlet
                Gregory Nikle Apprentice

                Is this important to use servlet to show report?
                Can u use SFSB in event/conversation scope instead?


                I use same on my page. I've got list of reports, user click on someone.
                In



                <s:link .. />

                i open new tab window in browser, and whole busines logic is managed in conversation scope SFSB for each report.
                after report close I clean everythink about this report.




                Maybe in servlet u redirect user to this page?
                Example:
                1. user click on link a href
                2. u get parameters?
                3. after somethink u want u redirect user to this page or not.