Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8496351
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:49:45+00:00 2026-06-10T23:49:45+00:00

I’m having a problem with my url. First, I have to display the image

  • 0

I’m having a problem with my url.
First, I have to display the image and the information of the image
But I need to click on a button to display my information.

This is the link with the image displayed and information not being displayed.
portal/faces/chicken.jsp?image_id=1

So, after i clicked the button. It becomes portal/faces/chicken.jsp

My code for retrieving the image needs the url image_id=1 as I’m using
request.getParameter(“image_id”) to display out the image.

This is the code for my button from the jsf:

<h:commandButton action="#{bean1.checkwork}" value="Get Info" type="submit">
    <f:param name="id" value="#{param['image_id']}"></f:param>
</h:commandButton>

This is the code for my faces-config.xml:

<navigation-rule>
    <from-view-id>/MainPage.jsp</from-view-id>
    <navigation-case>
        <from-action>#{bean1.checkwork}</from-action>
        <from-outcome>successful</from-outcome>
        <to-view-id>chicken.jsp?image_id=#{param['image_id']}</to-view-id>
    </navigation-case>
</navigation-rule>

This is the code for my function.

      public String checkwork()
      { 
           HttpServletRequest request = (HttpServletRequest)
           FacesContext.getCurrentInstance().getExternalContext().getRequest();
           String image_ID = null;
              if(request!=null)
              {
                   image_ID = request.getParameter("image_id");

                   images(image_ID);
                  student(matric);

               }
          else
          {
               System.out.println("fail");
                }

    return "successful";

}

So, does it have anything to do with the jsf, managed bean or the faces-config.xml?
Anyone knows the problem with my code?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T23:49:46+00:00Added an answer on June 10, 2026 at 11:49 pm

    It will indeed not appear in the URL anymore when you press the button, because the command button sends a POST request with the parameter in the request body instead of request URL. So the request parameter is definitely available. With a HTTP traffic checker (press F12 in Chrome/IE9/Firebug) you can see it.

    Your concrete problem is caused because you assigned the <f:param> a wrong name.

    <f:param name="id" value="#{param['image_id']}"></f:param>
    

    This way it would only be available by request.getParameter("id"), not by getParameter("image_id") as you attempted. Fix the name accordingly:

    <f:param name="image_id" value="#{param['image_id']}" />
    

    As to your concrete question about maintaining the URL after a “function” (“function” is the wrong term, you probably meant “method”, “action method”) is used, just use GET instead of POST. Use <h:button> instead of <h:commandButton>. You’ll only need to change the code to invoke the actual action in (post)constructor or <f:event preRenderView> of the bean associated with the target view.


    Unrelated to the concrete problem, there are nicer ways to grab it in your backing bean.

    String imageId = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("image_id");
    

    Having javax.servlet.* imports in your JSF code is namely a sign that you’re doing things possibly the clumsy way. Note that the request is never null (how else would the JSF code be executed?), so that nullcheck on request is also completely unnecessary.

    Another way is using @ManagedProperty:

    @ManagedProperty("#{param.image_id}")
    private String imageId; // +setter
    

    This works only on a request scoped bean though.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
This could be a duplicate question, but I have no idea what search terms
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.