submit form data to a new window failed using HTTP POST

Discussion in 'HTML' started by Matt, Aug 23, 2004.

  1. Matt

    Matt Guest

    The following program submit a FORM DATA to a new window using HTTP
    POST,
    and postprocess.jsp couldn't get the form data. If I do in GET method
    and pass by query string in windowURL, then it works. But I need HTTP
    POST method, and I cannot use target="_blank" because I need to
    control the new window's properties (disable the scrollbars, menubars,
    etc...)

    Are there any workarounds?

    <html>
    <script type="text/javascript">
    function checkAndSubmitForm(theForm)
    {
    var windowURL = theForm.action;
    window.open(windowURL, "newWin",
    "scrollbars=0,menubar=0,toolbar=0,location=0,status=0");
    }
    </script>

    <body>
    <FORM NAME="formname" method="POST" action="postprocess.jsp">
    <P><input type=text" name="username"/>
    <P><input type="button" name="submitBtn" value="Submit Form"
    onClick="checkAndSubmitForm(document.formname)">
    </FORM>
    </body>
    </html>

    postprocess.jsp is just one line statement to get the form data
    <%= Request.Form() %>


    any ideas? please help!! thanks!!
     
    Matt, Aug 23, 2004
    #1
    1. Advertising

  2. Matt

    Adrienne Guest

    Gazing into my crystal ball I observed (Matt)
    writing in news::

    > The following program submit a FORM DATA to a new window using HTTP
    > POST,
    > and postprocess.jsp couldn't get the form data. If I do in GET method
    > and pass by query string in windowURL, then it works. But I need HTTP
    > POST method, and I cannot use target="_blank" because I need to
    > control the new window's properties (disable the scrollbars, menubars,
    > etc...)


    Why do you want to do that? Please do not mess with my browser. I hate
    what you want to do.

    >
    > Are there any workarounds?


    Yes, submit to another page, sure, but just use the same window.

    >
    ><html>
    ><script type="text/javascript">
    > function checkAndSubmitForm(theForm)
    > {
    > var windowURL = theForm.action;
    > window.open(windowURL, "newWin",
    > "scrollbars=0,menubar=0,toolbar=0,location=0,status=0");
    > }
    ></script>


    Where is your HEAD element?

    >
    ><body>
    ><FORM NAME="formname" method="POST" action="postprocess.jsp">


    IIRC you must define the name of the form that is going to be used by your
    javascript here, so <form name="theform" method="post"
    action="postprocess.jsp">

    ><P><input type=text" name="username"/>
    ><P><input type="button" name="submitBtn" value="Submit Form"
    > onClick="checkAndSubmitForm(document.formname)"> </FORM> </body> </html>


    Your javascript is looking for the value of the action attribute of the
    form element. It will not know what to do because it is expecting
    "theform" and the value that is being passed is "formname".

    >
    > postprocess.jsp is just one line statement to get the form data
    ><%= Request.Form() %>
    >
    >
    > any ideas? please help!! thanks!!
    >


    Get rid of the idea of opening a window without menu, scrollbar, etc. Also
    think about visitors without javascript who will not get your silly window
    anyway.

    --
    Adrienne Boswell
    Please respond to the group so others can share
     
    Adrienne, Aug 23, 2004
    #2
    1. Advertising

  3. (Matt) wrote:

    > The following program submit a FORM DATA to a new window


    Well, it doesn't, but presumably you would like it to work that way.

    The best advice is: think twice before wanting that, and if the result is
    that you still want it, think again.

    > I cannot use target="_blank" because I need to
    >> control the new window's properties (disable the scrollbars, menubars,
    >> etc...)


    The second best advice is to use a target="..." attribute in a <form>
    tag, with a value that does not otherwise appear as window or frame name
    in your design, and use JavaScript to _only_ open a new window with that
    name and with the desired properties, leaving its content empty (it will
    be filled by your form handler, of course). For details & examples see
    http://www.cs.tut.fi/~jkorpela/forms/javascript.html#window

    > <input type="button" name="submitBtn" value="Submit Form"
    > onClick="checkAndSubmitForm(document.formname)">


    That way the form would not work at all when JavaScript is disabled or
    filtered out, and the user would see this only after filling out all the
    data and trying to click on the button. So use input type="submit".

    --
    Yucca, http://www.cs.tut.fi/~jkorpela/
    Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html
     
    Jukka K. Korpela, Aug 23, 2004
    #3
  4. Matt

    SpaceGirl Guest

    Adrienne wrote:

    > Gazing into my crystal ball I observed (Matt)
    > writing in news::
    >
    >
    >>The following program submit a FORM DATA to a new window using HTTP
    >>POST,
    >>and postprocess.jsp couldn't get the form data. If I do in GET method
    >>and pass by query string in windowURL, then it works. But I need HTTP
    >>POST method, and I cannot use target="_blank" because I need to
    >>control the new window's properties (disable the scrollbars, menubars,
    >>etc...)

    >
    >
    > Why do you want to do that? Please do not mess with my browser. I hate
    > what you want to do.
    >
    >
    >>Are there any workarounds?

    >
    >
    > Yes, submit to another page, sure, but just use the same window.
    >
    >
    >><html>
    >><script type="text/javascript">
    >>function checkAndSubmitForm(theForm)
    >>{
    >> var windowURL = theForm.action;
    >> window.open(windowURL, "newWin",
    >>"scrollbars=0,menubar=0,toolbar=0,location=0,status=0");
    >>}
    >></script>

    >
    >
    > Where is your HEAD element?
    >
    >
    >><body>
    >><FORM NAME="formname" method="POST" action="postprocess.jsp">

    >
    >
    > IIRC you must define the name of the form that is going to be used by your
    > javascript here, so <form name="theform" method="post"
    > action="postprocess.jsp">
    >
    >><P><input type=text" name="username"/>
    >><P><input type="button" name="submitBtn" value="Submit Form"
    >>onClick="checkAndSubmitForm(document.formname)"> </FORM> </body> </html>

    >
    >
    > Your javascript is looking for the value of the action attribute of the
    > form element. It will not know what to do because it is expecting
    > "theform" and the value that is being passed is "formname".
    >
    >
    >>postprocess.jsp is just one line statement to get the form data
    >><%= Request.Form() %>
    >>
    >>
    >>any ideas? please help!! thanks!!
    >>

    >
    >
    > Get rid of the idea of opening a window without menu, scrollbar, etc. Also
    > think about visitors without javascript who will not get your silly window
    > anyway.
    >


    Too generic. What if the page is on an Intranet, or part of an in-house
    application, or part of some extranet application? Then, just like any
    other software application, it'd be quite reasonable ask for things like
    this to be enabled...

    One of the projects I'm working on right now is a web-based application.
    It uses some nasty scripting, but that's fine as it's part of the
    specification of the application. It works in FF and IE, but it REQUIRES
    scripting, and REQUIRES degrees of window control. It says so on the
    back of the box the application ships in :)

    --


    x theSpaceGirl (miranda)

    # lead designer @ http://www.dhnewmedia.com #
    # remove NO SPAM to email, or use form on website #
     
    SpaceGirl, Aug 23, 2004
    #4
  5. Adrienne <> wrote in message > >
    > >
    > > any ideas? please help!! thanks!!
    > >

    >
    > Get rid of the idea of opening a window without menu, scrollbar, etc. Also
    > think about visitors without javascript who will not get your silly window
    > anyway.


    I fully agree on that!

    But you can do that by using <form action="blah.jsp" target="_blank">,
    but consider that seriously, 'cause opening pop-ups will get quite
    annoying. Plus that most of the time I use a browser it has pop-ups
    blocked, and so do many many other users as well.
     
    Juhani M?ntt?ri, Aug 23, 2004
    #5
  6. Robert Frost-Bridges, Aug 23, 2004
    #6
  7. Matt

    Mark Parnell Guest

    On Mon, 23 Aug 2004 10:00:44 +0100, SpaceGirl
    <> declared in alt.html:

    > Too generic. What if the page is on an Intranet, or part of an in-house
    > application, or part of some extranet application?


    Then the OP should have said that, as it is assumed that the question is
    in a www context, unless otherwise specified.

    --
    Mark Parnell
    http://www.clarkecomputers.com.au
    "Never drink rum&coke whilst reading usenet" - rf 2004
     
    Mark Parnell, Aug 24, 2004
    #7
  8. Matt

    Isofarro Guest

    Matt wrote:

    > postprocess.jsp is just one line statement to get the form data
    > <%= Request.Form() %>


    JSP? Unless you have defined and imported a static class called Request, or
    instantiated an object with the reference "Request", along with an oddly
    named method called "Form()", then the above isn't going to work.

    The form data in a JSP page is retrieved using the getParameter() method of
    the request object. So a field called "clientName" is retrieved using the
    expression <%= request.getParameter("clientName") %>




    --
    Isofarro.
    FAQ: http://www.html-faq.com/
    Recommended Hosting: http://www.affordablehost.com/
    isolani: http://www.isolani.co.uk/blog/
     
    Isofarro, Aug 27, 2004
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matt
    Replies:
    4
    Views:
    12,004
    vivekvsingh
    Sep 14, 2006
  2. Replies:
    2
    Views:
    6,300
  3. Matt
    Replies:
    1
    Views:
    262
    Bob Barrows [MVP]
    Aug 23, 2004
  4. Matt
    Replies:
    1
    Views:
    230
  5. Replies:
    2
    Views:
    378
Loading...

Share This Page