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

  • SEARCH
  • Home
  • 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 3681080
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T03:39:07+00:00 2026-05-19T03:39:07+00:00

I am using JSF framework and my requirement is to hit a URL e.g

  • 0

I am using JSF framework and my requirement is to hit a URL e.g http://localhost/jsfApp/us?param1=name&param2=pass.

Now I want to make a database call and fetch some data based on param1 & param2 even before any .jsp is displayed.

So is there any way to link the URL to any Bean/Java file where I could write the code for DB call, the result of which I will store in a ArrayList in the bean which will eventually be displayed on the .jsp file.

Thanks,
Narain

  • 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-19T03:39:08+00:00Added an answer on May 19, 2026 at 3:39 am

    Make param1 and param2 managed properties so that JSF will set them during bean’s construction.

    @ManagedProperty(value="#{param.param1}")
    private String param1;
    
    @ManagedProperty(value="#{param.param2}")
    private String param2;
    

    (or if you’re still on JSF 1.x, then you need to declare them as <managed-property> in faces-config.xml file instead)

    Then you can do the DB retrieval job in a postconstruct method which will be invoked directly after bean’s construction and all managed property setting.

    @PostConstruct
    public void init() {
        this.result = someDAO.find(param1, param2);
    }
    

    (or if you’re still on JSF 1.1 or older, then you need to upgrade to at least JSF 1.2 or better JSF 2.x)

    Finally just reference the result in the view.

    <p>Your result is: #{bean.result}</p>
    

    An alternative to @ManagedProperty in JSF 2.0 is the <f:metadata> in the view.

    <f:metadata>
        <f:viewParam name="param1" value="#{bean.param1}" />       
        <f:viewParam name="param2" value="#{bean.param2}" />       
    </f:metadata>
    

    This allows for more fine-grained control of validation and conversion of them.

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

Sidebar

Related Questions

When using the JSF Web application framework, ID of the elements inside a form
I'm using JSF/Facelets, and I'm trying to iterate over some Document objects (custom object)
How do I connect to the database(MYSQL) in connection bean using JSF to retrieve
How would I get the length of an ArrayList using a JSF EL expression?
I`m developing an application using Spring WebFlow 2, Facelets and JSF. One of my
Is there a way to create an html link using h:outputLink, other JSF tag
I don't see the point of using either http://960.gs or http://blueprintcss.org if they enforce
I have developed web applications using JSF (myfaces components). But in these days of
Enviroment: JSF 2.0, RichFaces 3.3.3, Facelets 1.1.15B1, Spring Framework 3.x, WebFlow 2.1, MyBatis 3.0.1,
I am using JSF 2.0 btw I have an attribute X type Integer, that

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.