How do I submit an HTML form, which is a String in my Servlet....need to post it from my Servlet?

I have a Servlet in a WebSphere Web Container.  I need to submit a page to another application in another Web Container running in WebLogic.

What I've done thus far is use the doGet() in my Servlet to retrieve some needed values from my login page out of the request object.  Then I opened a URLConnection to the other application and read in a form from their site.  

Now I have the entire HTML form stored in my Servlet as a String,
from the "<!DOCTYPE HTML PUBLIC "-//W3C//Dtd HTML 4.0 Transitional//EN"><html>"
to the </html>.  

Their form does a POST and the ACTION passes in something like

FORM NAME="LoginForm" METHOD="POST" ACTION="VP;jsessionid=2CqLONoS8guu78brXG33q2JsJL8IGK3cKF0w9lU1k47F2UUG28e5!-1627733873!152169157!7002!7022">

The jsessionid was established with I read the page from the URLConnection.  The form is pretty simple,
a couple of input text fields and serveral hidden field.

So I need to submit this form.  It performs a login on the other application.

I tried a resp.sendRedirect( "http://server:7002/VP;jsessionid=2Dle1E45iqBrIziJcPWtE3ChsfzYphQiLg3QWePuHI5zUtqHCPCF!-1627733873!152169157!7002!7022" )

But this displays an error on their page.  Don't this this is really submitting that form String in my Servlet.  I don't believe forwards will work because I think you need to forward to a URL in the same Web Container.  Same goes for includes, they more or less get bounced back to my doGet().

I think I can open another URLConnection or Socket back to the server, but not sure how to POST this and keep it from coming back to my doGet().

Any help would be greatly, greatly appreciated.
jredAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sfotexCommented:
I think you want to create a new  http connection to the server in your servlet and submit your info,
You probally don't  want to do a redirect b/c that
will divert the user to the other site, where it sounds like you want to signal the other server of a login...
0
jredAuthor Commented:
Yes, I want the other server to do the login and return me the next page, so my Servlet more or less becomes the middle man.

How would I create a new HTTP Connection and submit the login form?
0
jredAuthor Commented:
Yes, I want the other server to do the login and return me the next page, so my Servlet more or less becomes the middle man.

How would I create a new HTTP Connection and submit the login form?
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

jerelwCommented:
1.simulate a post e.g. - http://www.javaworld.com/javatips/jw-javatip34_p.html)

2.read in your InputStream
3.display your scraped page
0
victorliCommented:
The "<Form name=... method=... >... </Form>" kind stuff is only run in client side which means in browesr. They have no place in your server component. Like Java applet or javascript, what can you do with them in your servlet or jsp?

Try this:
(1) Check the url and login parameters of another web site. Suppose their form action is "http://anotherside/login.jsp
the login name prameter key is "thatName" and password key is "thatPswd". It is easy to get the above information.
(2) in your servlet, forget about URLConnection, try the following:

String userName = request.getParameter("thisName");
String pswd = request.getParameter("thisPassword");

response.sendRedirect("http://anotherside/login.jsp?thatName="+userName+"&thatPswd="+pswd);  
0
victorliCommented:
What I mean "the form element has no place in your server component" is you can not submit a form in server side. Of course you can embed them in your servlet and send them to client side to submit.
0
CleanupPingCommented:
jred:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
jimmackCommented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

PAQ - No refund

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jimmack
EE Cleanup Volunteer
0
YensidModCommented:
This question is PAQed  and no points refunded (of 100).

YensidMod
Community Support Moderator
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java EE

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.