Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help needeed on URL and URLConnection classes

 
praveen sainath
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ppl,
I have an requirment to call an servlet from a jsp, but that servlet requires authentication, i have the user information in the jsp.
My requirment is to connenct to the servlet with user information to login first, using URL or URLConnection classes and then using the same connection I have to call the servlet again with different parameters..

for example ,
If "/publish" is my servlet I will pass
?module=com.med.phd.LoginModule&action=verify&user=xxx&password=yyy
first
and then
call the same "/publish" servlet with different set of parameters

Can anyone help me on this pls..it is very urgent!!!
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to Servlets forum...
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by praveen sainath:
...Can anyone help me on this pls..it is very urgent!!!


praveen sainath,
Welcome to JavaRanch!

In an effort to help you get the most from our forums, we've compiled a
list of tips for asking questions here. You can find the list in our
FAQ section here.
In particular please see:
EaseUp to learn how putting "Urgent" in your post or subject line can actually slow down or eliminate responses to your question altogether.

Again, welcome to JavaRanch and good luck with your question.
-Ben
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13064
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an requirment to call an servlet from a jsp, but that servlet requires authentication,


What does the servlet do once it has authenticated a user?

If it creates a session, the cookie identifying that session will be passed back in the response to the authentication request. Your task will be to locate that cookie and send it with subsequent requests so the servlet will consider the user authenticated.

The open source HttpClient toolkit might be what you need, or you can try to handle the cookie directly by examining the header sent in the response.

Note: if the url you address starts with http:// you will actually be dealing with a HttpURLConnection - see the java.net package documentation.

Bill
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm confused. Does "calling the servlet from a JSP" mean that the URL is part of a link or form submit on a web page? If so, how would you use client-side Java classes?

Can you pass all required parameters to the LoginModule URL, and have that forward the request to whichever servlet it's supposed to go to?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic