How does browser know where to post form?


Web tier: servlets, JSP, Web frameworks: How does browser know where to post form?

  1. How does browser know where to post form? (3 messages)

    I am using struts 1.1, tiles and wl6.1

    My application is at localhost:port/applicname/*

    After i do a get request to localhost:port/applicname/, i do get the login page.

    However, when i do a javascript:submit(), it tries to go to
    localhost:port/ instead of localhost:port/applicname/

    my form element is as follows:
    <form name="loginForm" action="/">

    Any idea why this is happening??

    my struts-config entry is as follow:


                <forward name="nextview"

    The application is deployed properly an .ear file.
    that is the context of the application is set as "applicname" in the application.xml file.

    Do i need some entry in the web.xml or anywhere else that would help the browser request as localhost:port/applicname/* everytime?

    By the way how does the browser know that it has to submit to localhost:port/applicname/ if the action is

    thanks a lot!
  2. The request is going to the right URI (/
    You could either remove the / to indicate that it should go to the current path or you should use URL-rewriting.

    Barre Dijkstra
  3. Hello,

    you should use the Struts html taglib for generating the html form. It will construct the correct url by prepending the application's name to the action path.


    <html:form action="/">


  4. thanks a lot guys...both of ur solns worked!!!