Question

I have a html page and i am sending some parameter using post method. now i want to get these parameter on gwt client. is there any method in gwt to get post parameter on client.? i use following code

 <html>
<body>
<form action="http://localhost:8080/popnnn/js.html" method="post">
  <input type="text" id="foo" name="foo">
  <input type="submit" value="Send" name="submit" id="submit">
</form>
</body>
</html>

and in my gwt code

 TextBox text=new TextBox();
 text.setText(Window.Location.getParameter("foo"));

this is perfectly woking with get method but not with post please help......

Was it helpful?

Solution

Steps to follow:

  • Just convert the file js.html to js.jsp.
  • Get the post parameter from the request parameter.
  • Set the value in hidden div in JSP and access it in JAVA.
  • Change the action attribute of form tag as shown below:

    <form action="http://localhost:8080/popnnn/js.jsp" method="post">
    

Try any one:

  • JSP Scriplets

    <div id="fooParameter" style="visibility: hidden;">
         <%=request.getParameter("foo") %>
    </div>
    
  • JSP Standard Tag Library

    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    <div id="fooParameter" style="visibility: hidden;">
        <c:out value="${param.foo}" />
    </div>
    

Access value from hosted HTML/JSP to JAVA code

String foo = RootPanel.get("fooParameter").getElement().getInnerHTML();

TextBox text=new TextBox();
text.setText(foo);

Find a sample code here about Acces value between two jsp with jstl

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top