Win a copy of Microservices Testing (Live Project) this week in the Spring 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

setting attributes and using sendRedirect

 
Ranch Hand
Posts: 528
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi , Is this possible to do ?


session.setAttribute("bean",EmpBean);

response.sendRedirect("/myjsp.jsp");// Assuming that myjsp.jsp within the same context/server(part of the web application)

Can i access this EmpBean info in myjsp.jsp page as i am not using RequestDispatcher forward , and only using sendRedirect()???
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes, you can . since session is a representation of a loggedin user
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When you want to redirect the request to a different URL, but still want to use a session. There is a special URL encoding method just for that.

response.encodeRedirectURL("/BeerTest.do");
 
RaviNada Kiran
Ranch Hand
Posts: 528
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

sandeep yel wrote:When you want to redirect the request to a different URL, but still want to use a session. There is a special URL encoding method just for that.

response.encodeRedirectURL("/BeerTest.do");



Thanks for your information seetha,

sandeep , when i want to access other site for example www.google.com , by using encodeRedirectURL("/BeerTest.do") and return type of it into sendRedirect() , we can maintain session id on other site also , but i think we can't carry data as in my case EmpBean into google.com to access it from there??
 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

seetharaman venkatasamy wrote:yes, you can . since session is a representation of a loggedin user

You're totally wrong.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

sandeep yel wrote:When you want to redirect the request to a different URL, but still want to use a session. There is a special URL encoding method just for that.

response.encodeRedirectURL("/BeerTest.do");


This is only applicable if the client has cookies disabled and still then, the URL has to stay in the same context.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

RaviNada Kiran wrote:

sandeep yel wrote:When you want to redirect the request to a different URL, but still want to use a session. There is a special URL encoding method just for that.

response.encodeRedirectURL("/BeerTest.do");



Thanks for your information seetha,

sandeep , when i want to access other site for example www.google.com , by using encodeRedirectURL("/BeerTest.do") and return type of it into sendRedirect() , we can maintain session id on other site also , but i think we can't carry data as in my case EmpBean into google.com to access it from there??

No, that is certainly not the case. The session is domain-specific. That would have been a huge security hole otherwise.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bauke Scholtz wrote:

seetharaman venkatasamy wrote:yes, you can . since session is a representation of a loggedin user

You're totally wrong.



Hi Bauke ,

if you dont mind, can you elaborate my fault
 
RaviNada Kiran
Ranch Hand
Posts: 528
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Bauke Scholtz for your valuable information on this,

Then how shall i carry the session information outside the domain ??
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Pass it (or its identifier if both have a shared datasource) as request parameter or at least as part of request URL. That's all what you can do.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

seetharaman venkatasamy wrote:

Bauke Scholtz wrote:

seetharaman venkatasamy wrote:yes, you can . since session is a representation of a loggedin user

You're totally wrong.



Hi Bauke ,

if you dont mind, can you elaborate my fault

A session does in no way represent a logged in user. That you can store the logged in user in there doesn´t make it different.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bauke Scholtz wrote:A session does in no way represent a logged in user. That you can store the logged in user in there doesn´t make it different.



Well Bauke . but you can set the value into the session also (you can get it after the redirect)right ?
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If in the same domain and context (thus also the same session), yes.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks bauke
 
RaviNada Kiran
Ranch Hand
Posts: 528
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your conversation made me more clear on this .Thanks once again to both of you.
 
reply
    Bookmark Topic Watch Topic
  • New Topic