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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:38:31+00:00 2026-06-12T09:38:31+00:00

Today I’m using a servlet to receive a POST from a HTML page and

  • 0

Today I’m using a servlet to receive a POST from a HTML page and then redirecting to my JSF page.

This is my actual Servlet:

   public class CommInServlet extends HttpServlet {

   private String reportKey;

      protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
         req.getSession(true).setAttribute("reportKey", req.getParameter("reportkey"));
         req.getRequestDispatcher("main.xhtml").forward(req, resp);
       }

    }

HTML post page:

<html>
<head />
<body>
<form action="Filtro" method="post">
<input type="text" size="120" name="reportkey" value="XXXXXXXXXXXX" />
<input type="submit" value="doPost" />
</form>
</body>
</html>

Is it possible to post directly to my JSF page (ManagedBean)? How?
I want to replace the Servlet for something… better.

  • 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-12T09:38:32+00:00Added an answer on June 12, 2026 at 9:38 am

    Sure you can. Most JSF requests are POSTs anyway, so if you use the path to the JSF page you’re intending to handle the POST request, you can then get the parameter within a managed bean that is backed by that page OR get the parameter within the page itself.

    Within a managed bean:

         @PostConstruct
          public void initMyBean(){
          /**This map contains all the params you submitted from the html form */
          Map<String,String> requestParams = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
          requestParams.get("reportKey");
                           }
    

    OR
    within the managed bean have

         @ManagedProperty(value="#{param.reportKey}")
         String reportKey;
         //getter and setter of course!
    

    The method you’ve annotated with @PostConstruct will be executed after the managed bean has been instantiated. The above will give you access within your managed bean.

    If you need the value within your page first however, you can have this in your page (preferably at the top)

         <f:metadata>
          <f:viewParam name="reportKey" value="#{backingBean.reportKey}" required="true"/>
         </f:metadata>
    

    Notice how you can perform validations on the parameter from within your view. Pretty cool feature.

    Just be sure and set your html form action attribute to the path of the JSF view.

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

Sidebar

Related Questions

Today, reading Servlet 3.0 specification, I've come across a sentence: We emphasize that this
Today, I saw this article on Twitter about getting Webm data from a canvas:
Today, I ran into this weird problem with a user using Mac OS X.
Today I generated a webservice client with CXF 2.6.1 (latest version), using the tool
Today I am trying to remove some bytes from an EXE file. Inside the
Today I migrated an old application from EF 4.2 to EF 4.3.1. In my
Today I experienced a very strange behavior with my XCode (using Version 4.2, iOS
Today morning I wake with this weird issue where mongoid was creating a record
Today start using the new version of Netbeans 7.1.2, I get the below notice
Today I'd like to know some features on the JSF Lifecycle. Let me start

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.