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 6643031
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:00:02+00:00 2026-05-26T00:00:02+00:00

I have recently started learning Java EE 6 and I could need some help.

  • 0

I have recently started learning Java EE 6 and I could need some help. I have made a search.xhtml page that has a form, some fields and a commandbutton. The action invokes a method in the managed bean and returns a string. However the url-field in the browser does not update to search-results.xhtml which is the other page with the results. It shows the content inside the search.xhtml page (but it seems like it get the layout and all that from the search-results.xhtml).

(it is very simple, not doing much at this time)

@ManagedBean
@RequestScoped
public class Search {

private SearchBackingBean searchBackingBean;
private ArrayList<String> list;

public Search() {
    searchBackingBean = new SearchBackingBean();
    list = new ArrayList<String>();
}

public String find() {
    return "search-results";
}

search.xhtml

<h:form>

    <h:inputText value="#{search.searchBackingBean.query}" 
                 size="60"
                 required="true"
                 requiredMessage="Please enter what you want to search for." />
    <h:commandButton value="Find" action="#{search.find}" /><br />

    <h:outputText value="Search criterias to be included in your search." /><br />
</h:form>
  • 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-05-26T00:00:02+00:00Added an answer on May 26, 2026 at 12:00 am

    Basically, you’re sending a POST request on the very same <form action> URL as the initial page you’re viewing and during postprocessing telling JSF to use the given target page to display the results. It uses internally RequestDispatcher#forward() to forward the request/response to the given destination. This takes place entirely in the server side. If you’re familiar with the basic Servlet API (which JSF uses under the covers), then you should understand its working.

    If you want a change in the browser address bar URL, then you basically need to change the <form action> URL to the desired URL (which isn’t possible in standard JSF without manipulating the ViewHandler based on some configuration file), or to send a fullworthy redirect after POST by adding ?faces-redirect=true to the outcome.

    return "search-results?faces-redirect=true";
    

    The redirect basically instructs the webbrowser to send a new GET request on the given URL, so the URL in address bar will change. The disadvantage is, however, that all request scoped beans are garbaged and recreated (because a redirect is a new request!) and you’ll thus lose the search results.

    I’m not sure why you want to have the URL changed, but if you want to make it bookmarkable, then you shouldn’t use <h:form> (which defaults to POST), but just a plain HTML <form> (which defaults to GET) with plain HTML inputs and button and define the parameters as <f:viewParam> in the target page so that JSF will set them in the bean associated with the target page.

    E.g. in the search form:

    <form action="search-results.xhtml">
        <input name="query" size="60" />
        <input type="submit" value="Find" />
    </form>
    

    and in the result page:

    <f:metadata>
        <f:viewParam name="query" value="#{search.query}" required="true" requiredMessage="Please enter what you want to search for." />
        <f:event type="preRenderView" listener="#{search.find}" />
    <f:metadata>
    

    (by the way, I’d prefer to combine them in a single page and render the results conditionally using rendered attribute)

    Note that your SearchBackingBean is IMO wrongly named. It’s not a backing bean. It’s just an entity (or POJO or DTO or whatever you’d like to name it). Your Search class is the real backing bean.

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

Sidebar

Related Questions

I've been a web developer for some time now, and have recently started learning
I just recently started learning Java. I have a question which is more about
I have recently started learning java as my first ever step into object oriented
I have recently started learning F#, and this is the first time I've ever
I have recently started learning Perl and one of my latest assignments involves searching
I have recently started working on a very large C++ project that, after completing
I have recently started seeing user agents like Java/1.6.0_14 (and variations) on my site
I have recently started learning C++, but I require a compiler. I have tried
I have recently started learning C++ and coming from a Ruby environment I have
I have recently started learning Python and I have 2 questions relating to modules.

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.