This week's book giveaways are in the Cloud and AI/ML forums.
We're giving away four copies each of Cloud Native Patterns and Natural Language Processing and have the authors on-line!
See this thread and this one for details.
Win a copy of Cloud Native PatternsE this week in the Cloud forum
or Natural Language Processing in the AI/ML forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

sendRedirect(singlesignon)

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I will be getting a request from a secured site like https://www.x.com?id=12&value=1234.
I have written a servlet to map the keys id and value to different values
and formed a query string like id1=12&value1=1234.
Then I have to post the data to another servlet which accepts this id1 and value1.I have done it using sendRedirect.This servlet does the client verification etc and calls another servlet which creates a session and my servlet has to recieve the session ID and pass it back to the client(Single signon)
My quetion is
1)Is it safe to use sendRedirect and is there any other way to post the data to that servlet.
2)How will make my servlet receive the session Id.Do the servlet which handles the session has to post the session Id back to me.
Thanx
 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sendRedirect tells the user's web browser to request a different page. Your servlet then has nothing more to do with it. There is no way you can get at the results of that request.
If you want your servlet to log onto another web site on behalf of a user then it will need to act as if it was a web browser. You could investigate the Apache httpclient package for that.
Single sign-on (involving multiple sites) is quite a complex issue, and there really no easy solution.
 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use javax.servlet.RequestDispatcher to add parameters to the request
and forwad it to another servlet for processing.
Ex:
// Set attributes
req.setAttribute("id1", new Integer(12));
// Get dispatcher with a relative URL
RequestDispatcher dis = req.getRequestDispatcher("../AnotherServlet");
// or forward
dis.forward(req, res);
Gayan Balasooriya
SCJP,SCWCD
http://www.gayanb.com - Free Java/J2EE/J2ME books and mock exams
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use RequestDispatcher instead, for example http://www.ideas2work.com

Originally posted by raj guntupalli:
I will be getting a request from a secured site like https://www.x.com?id=12&value=1234.
I have written a servlet to map the keys id and value to different values
and formed a query string like id1=12&value1=1234.
Then I have to post the data to another servlet which accepts this id1 and value1.I have done it using sendRedirect.This servlet does the client verification etc and calls another servlet which creates a session and my servlet has to recieve the session ID and pass it back to the client(Single signon)
My quetion is
1)Is it safe to use sendRedirect and is there any other way to post the data to that servlet.
2)How will make my servlet receive the session Id.Do the servlet which handles the session has to post the session Id back to me.
Thanx

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!