• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

doGet() calling doPost() problem -- URL line visible in destination page!

 
Bartender
Posts: 1971
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I call my Servlet from a JSP page with a dispatcher.forward(request, response).
What gets executed in the Servlet is the doGet().
OK.
The problem is that when I pass the doGet() in the Servlet on to the doPost() in the Servlet (with doPost(request, resposne) and the servlet's doPost() forwards the response on to the JSP page to actually start, the URL line in the browser has the parameters in it!
If I just use the Web App's login form and only hit the doPost() of the Servlet (and not the doGet()), then I get the desired behavior and do not see the URL parameters.
This is confusing.
I can't understand how to supress the URL parameters. It seems no matter what I do, I'm getting "get" behavior.
I've tried using both response.SendRedirect(<url parameters> and dispather.forward (request, response), but both have this same behavior.
Any ideas would be GREATLY appreciated!!! <s>
Thanks.
-- Mike
 
Ranch Hand
Posts: 405
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a couple of suggestions. Couldn't you pass the request/response object thru the html FORM element. You could set the METHOD attribute to "POST".
Another solution would be to store your information in the ServletRequest scope using the setAtrribute/getAttribute methods.
Craig.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What the browser shows is the URL that it submitted to the server. Whether you call doPost or forward from that point is completely moot. The method of the request is set by how it is initiated by the browser.
So how are you generating the inital request? If it's a GET, nothing can change it to a post. You need to make sure that your original request uses the POST method.
 
Mike London
Bartender
Posts: 1971
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bear,
From Visual FoxPro, I'm calling IE and passing it a URL, like this:
lccmd='run /n7 "C:\Program Files\Internet Explorer\iexplore.exe" ;
http://'+gcWebHost+'/index.jsp'+ ;
'?txtlogin='+STRTRAN(ALLTRIM(USERID),' ','%20')+;
'&txtpassword='+STRTRAN(ALLTRIM(lcPassword),' ','%20')+;
'&fName='+STRTRAN(ALLTRIM(fname),' ','%20')+;
'&lName='+STRTRAN(ALLTRIM(lname),' ','%20') + CHR(13)
---------------
**********************************************
Then, in index.jsp, I do something like this:
**********************************************
RequestDispatcher disp = request.getRequestDispatcher("dispatcher");
.
. (more code to do request.getParameter(...)s)
.
disp.forward(request,response);

}
**********************************************
The dispatcher is a Servlet.
**********************************************
The "forward" above comes into the Servlet's doGet().
I then forward the (request,response) to the Servlet's doPost().
The doPost in the Servlet code finally calls the JSP page that is the Web App. However, when the Web App starts up, using the above methodology, you SEE the passwords and other private stuff inside the Web App.
I need some kind of way of doing a POST without having to manually log in and click SUBMIT.
-------
Does this information help?
Can I get the "hidden URL" doPost() behavior in some way?
Thank you very much for your reply.
I look forward to hearing back.
Thanks much!!!
-- Mike
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Looks like this might be a job for a Filter to me. Your filter for the servlet would substitute your custom HttpServletRequestWrapper which would then be forwarded to the JSP. The custom class would have to return "POST" to the getMethod() call and would probably have to have other modifications.
Seems to me we have had a number of Threads like this recently, why don't you browse around in the recent history.
Bill
 
Mike London
Bartender
Posts: 1971
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bill,
This sounds interesting, but is a bit vague. I'll look around and let you know what I find.
Thanks.
-- Mike
 
Craig Jackson
Ranch Hand
Posts: 405
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I will try to elaborate.

First of all you should never send sensitive information i.e. logon, password as part of an url, so everyone can see.
Based on your example:

lccmd='run /n7 "C:\Program Files\Internet Explorer\iexplore.exe" ;
http://'+gcWebHost+'/index.jsp'+ ;
'?txtlogin='+STRTRAN(ALLTRIM(USERID),' ','%20')+;
'&txtpassword='+STRTRAN(ALLTRIM(lcPassword),' ','%20')+;
'&fName='+STRTRAN(ALLTRIM(fname),' ','%20')+;
'&lName='+STRTRAN(ALLTRIM(lname),' ','%20') + CHR(13)


You are using the "GET" method by default. As Bear pointed out, this will follow the request until, I guess it goes out of scope.
Now there are several suggestions to get around this.
1. You can access your servlet thru the html FORM tag, by setting the METHOD attribute to "POST". You can do this by enclosing your code in a jsp page.
2.Storing the information in the ServletRequest object(i.e. setAttribute, getAttribute).
3. Wrapping the request in a HttpServletRequestWrapper object were you provide your own implementation of the getMethod, so as to return "POST" per Mr Brogden.

I hope this helps.
Craig
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Looks like this might be a job for a Filter to me.


That was my first thought. But I'm not sure that this would prevent the browser from showing the original full URL or not. Not something I've fooled with.
Apparently the FoxPro mechanism doesn't have any means to submit form data rather than a query-stringed URL?
 
Mike London
Bartender
Posts: 1971
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys,
OK, I'm not sure what it means to "access the servlet though the HTML form tag". The problem is that the Visual FoxPro application is starting up IE and passing a GET string to either the JSP page or to the Servlet. POST is already the default in the JSP page, but when I re-direct (forward) it to the Servlet, it still comes across as a "get" (all URL parameters visible). Not sure if this is what you meant.
Can you clarify?
I have no idea how to do number 3 you listed. Yikes!
Does anyone have an example of how to: "Wrapping the request in a HttpServletRequestWrapper object were you provide your own implementation of the getMethod, so as to return "POST" per Mr Brogden."
I appreciate everyone's replies.
Hope to hear back...
-- Mike
 
Mike London
Bartender
Posts: 1971
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I can access the servlet from Visual FoxPro using an in-process ActiveX control.
The problem in this case is that IE has not been started so, although I have POSTed the data to the Servlet, there's no Web Application loaded.
Sigh...
-- Mike
 
Ranch Hand
Posts: 403
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you try something along the lines of invoking IE through automation:
This partial example is in javascript (not too familiar with FoxPro syntax)

Based on this reference:
http://msdn.microsoft.com/workshop/browser/webbrowser/reference/methods/navigate.asp
You need to encode "postData" some how for the method to recognise that you are trying to do a post.
 
F is for finger. Can you stick your finger in your nose? Doesn't that feel nice? Now try this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic