0 Replies Latest reply on Feb 25, 2002 6:01 AM by cheesus

    construct self-referencing URL in jsp file

      Hi all,

      in my JSP files, I include a a general header file
      that contains a standard header, logo etc as well as
      displaying the user currently logged in and a logout
      button.
      Since my web app is to be multi-lingual, I also wanted to
      have the language switch-over in that toolbar.

      What I did is the following:

      <form action="MyServlet" method=POST>
      Current language: <%=session.getAttribute("lang");%>
      <input type=submit value="Toggle language" name=tglLang>


      Which works to switch the language, however, since I
      adress the MyServlet "application home page", the
      language switch will always go back there.

      What I really want is to reference the same page that is
      currently displayed. Since the header is included, this
      URL cannot be hardcoded but has to be constructed from
      any one of page, pageContect, session, request, response,
      ... variables available in the JSP.

      However, I did not manage to construct a FULL
      self.reference containing server name, page name and
      path, session URL (in case of rewriting) and GET request
      parameters.

      I would not like to use JavaScript for this.

      Any thoughts anybody ?

      best regards, tom.