Results 1 to 6 of 6
  1. #1
    mwildam's Avatar
    mwildam is offline Member
    Join Date
    Aug 2007
    Posts
    72
    Rep Power
    0

    Question JSF Request value on Page2

    I created a new JSF project in NetBeans and I managed displaying a page with some elements and a button. In the faces-config.xml I setup moving to Page2.jsp on submission.

    Then - in the init method in the java file of page2 I want to get form values posted from page2.

    How do I manage this in java code?

    And how do I retrieve the session id?

    I didn't find helpful information searching.
    Greetings, Martin Wildam.

  2. #2
    Raghuvasa is offline Member
    Join Date
    Oct 2008
    Posts
    5
    Rep Power
    0

    Default

    you can get session id by getting Facesconttext object.

    FacesContext context = FacesContext.getCurrentInstance();
    HttpSession session = (HttpSession) context.getExternalContext().getSession(false);
    session.setAttribute(”sessionObj”, mySession);

    and

    i didnt get what exactly u want for the request fields.
    and by what iam understanding you can get the from field values. just u post the values through <inputhidden > tag and maintain the scope in session then u can get the values where do u want

  3. #3
    mwildam's Avatar
    mwildam is offline Member
    Join Date
    Aug 2007
    Posts
    72
    Rep Power
    0

    Default

    The request-question was about normal form fields - when I have a second page and I want to retrieve the values of the form fields posted from page1 to page2 - how to do it?
    Greetings, Martin Wildam.

  4. #4
    mwildam's Avatar
    mwildam is offline Member
    Join Date
    Aug 2007
    Posts
    72
    Rep Power
    0

    Default

    Thanks for your hints - playing a little around starting from your suggestions I found out how to retrieve parameters (just some dirty sample):
    Java Code:
            FacesContext finst = FacesContext.getCurrentInstance();
            ExternalContext ext = finst.getExternalContext();
            HttpSession session = (HttpSession) ext.getSession(false);
            Enumeration<String> atts = session.getAttributeNames();
            result = "Session attributes: \r\n";
            while (atts.hasMoreElements())
            {
                String attrName = atts.nextElement();
                result += attrName + "=" + session.getAttribute(result) + "\r\n";
            }
            result += "\r\n\r\n";
    
            Iterator<String> it = ext.getRequestParameterNames();
            Map props = ext.getRequestParameterMap();
            while (it.hasNext())
            {
                String pName = it.next();
                result += pName + "=" + props.get(pName).toString() + "\r\n";
            }
    Greetings, Martin Wildam.

  5. #5
    Raghuvasa is offline Member
    Join Date
    Oct 2008
    Posts
    5
    Rep Power
    0

    Default

    Thanks Martin Wildam.

  6. #6
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    7

    Default

    Quote Originally Posted by xseahawksx View Post
    Check the Files Clearly
    What files? Did you read the thread? They already solved their problem on 9 December 2008.

Similar Threads

  1. [SOLVED] http request
    By Eranga in forum Advanced Java
    Replies: 30
    Last Post: 11-27-2008, 04:35 AM
  2. request.get not using generics
    By Nicholas Jordan in forum Java Servlet
    Replies: 4
    Last Post: 07-27-2008, 02:09 PM
  3. Session and request in JSF
    By felixtfelix in forum Web Frameworks
    Replies: 0
    Last Post: 05-08-2008, 05:10 PM
  4. respose with out request
    By karthikiniyan in forum Java Servlet
    Replies: 1
    Last Post: 04-09-2008, 03:06 PM
  5. Help with request.getParameter()
    By Albert in forum Enterprise JavaBeans (EJB)
    Replies: 1
    Last Post: 07-13-2007, 03:39 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •