While using GWT FormPanel, after submitting the form, it posts form but does not redirect to the action url.
Can any body help me?
formPanelObject.getElement().<FormElement>cast().setTarget("");
by this line you changing the target parameter of the form and now the main page redirected to the action url after calling formPanelObject.submit();.
Related
After submitting a form, calling an action and redirecting to show the jsp, the final url of the browser will show the action with the submit parameters as follows. Is it possible to hide the parameters ?
http://localhost:8080/myproject/login?username=aaa&password=123
Use "redirect" result type to send the redirect to the browser. The parameters should still be in your session/action context.
The comment by #sanbhat is right - use a POST request so that the parameters do not appear in the URL. Using browser dev tools or similar it's still possible to inspect the request and it's post data, there's nothing you can do about that.
In the final redirect to the result JSP, (which presumably shows what the user wrote on the form), then the fields can be populated by saving the results in session scope, so no need to have request parameters on the redirect URL.
i guess you are making a GET call here..
in the submit action make sure you specify method="post" so that password wont appear as parameter
You are using get method. Change it to post method. Example is:
form method="post" name="form name" action="Your action page"
use post method in the form , default is get so u always see the parameters in the url.
<form action="some.jsp" method="post">
i know that this is probably asked previewsly but i didnt find a solution yet.
So the case is that i want to make a (do or get) request to a servlet from an anchor in a jsp file and not from a form.Is that possible?
When you click an anchor link, you're sending a GET request, so doGet() gets invoked.
You cannot do a post request by clicking such a link. HTML anchors are not designed that way.
You can use Ajax, if you don't want to submit a FORM
or atleast you can trigger a form submission onclick of it.
$("link").click(function(){
$("#form").submit();
});
I am creating a web application in Java. I created some JSP pages each having some form fields. All are post method type so it hides all the form fields. In each page it will call servlet and forward to next JSP page(like a step by step process.)) Welcome page is index.jsp. In the last JSP page also I am having form field which is also post method type. When I press sumbit button, it will call servlet and should forwartd to home page(That is index.jsp).
Last page action value is finish. In my servlet, I am using RequestDispatcher and forwarding to index.jsp. The the URL will be
http://localhost:8080/myproject/finish.
As it is the home page, I wanted to hide that action value. So instead of RequestDispatcher I used
response.sendRedirect("index.jsp"); And then URL becomes
http://localhost:8080/myproject/index.jsp.
This is not a big issue. But still I am asking is there anyway to hide this index.jsp in the URL? It should be like when we open the site for the first time(http://localhost:8080/myproject/).
I got the answer finally. Thanks to #Sayem Ahmed for his reply as comments.
I tried this only
response.sendRedirect("/myproject");
I want to login into a website. I need to identify the url to login. The view source shows post method as follows.
<form id="signIn" onsubmit="return false;" action="/f1/logon" method="post">
I see that there is no javascript that validates the url.
When i use the below url directly on a browser,
https://www.abc.com/f1/logon
I get a blank page. When I use below,
https://www.abc.com/logon
I dont see the repsonse of the loggedin page. It shows the response of the signin page though. How do i identify the correct url to autologin. downloaded soem toold like fiddler but no help. any inputs?
Invoking a URL in a browser sends a GET request. This form, however, is configured to send a POST request (look at the method attribute), so it makes sense that you are not seeing anything in your browser.
It's strange that the onsubmit attribute returns false. This prevents the form from being submitted at all. Take a look at the "login" button. There may be some Javascript code there which does the form submission.
Fidller is a good tool, you can start capture job and then you perform a login. Find which request contain your login and password.
Hi all
I've got some jsp pages and im using struts to handle my forms.
After submitting a form by user, the url shown in address bar becomes somthing.action, so when the user refreshes the page, the forms gets submitted again.
How can I handle this?
after submission of a form, Is there any possible way to show a ".jsp" url instead of a ".action" in the address bar?
Yes, use redirect-after-post. Either response.sendRedirect("foo.jsp"), or see here or here (depending on what exactly your code is).
If you are using Struts 2, it has a Token interceptor, to prevent duplicate form submissions -
http://struts.apache.org/2.1.2/struts2-core/apidocs/org/apache/struts2/interceptor/TokenInterceptor.html
And an example: https://cwiki.apache.org/WW/token-interceptor.html
If you redirect user to some page (it can by same as form) after you make action, it will not send post data if page will by refreshed.