Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

retieve session without request object  RSS feed

 
Brijesh Sah
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My Code is as follows:
void sendmail(String Mailcode,String name,String fromid,String toid,String extra){
//Some code here

name=(String)session.getAttribute("SALUTATION")+" "+name;
//Some Code Here
}

I want to add SALUTATION name before name which is set as session variable.
so that email can go like Dear Mr. Brijesh,
Please help otherwise i have to change many classes
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do it before passing it as method parameter.
 
Brijesh Sah
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If i want to this thing inside this method only otherwise there could me major code changes
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't. There is no magic, you know?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The most flexible approach is to create a collection and pass that to the method.

Just add everything the method will need to the collection, then you call to sendmail becomes very simple:

void sendmail( Map mailparams )

One great virtue of this approach is that you can add or remove objects in the collection as your application evolves without changing the method signature.

Another virtue is that the code can now be tested OUTSIDE the servlet environment - a really big plus in my opinion.

Bill
 
Brijesh Sah
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks For your replies.

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