• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

setting up context variable

 
Nikhil Muskur
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
i want to access an int variable in other servlet plzzz help me ......cant complete my project :cry
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65335
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What have you tried? What part isn't working?
 
Nikhil Muskur
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


i want to access the total variable in other servlet.........so can you tell me the proper way
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65335
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First of all, you should not be creating HTML in a servlet -- you should forward to a JSP to create the HTML view after the servlet is done dealing with the data.

To share a scoped a variable place it in session scope if it is specific to the current user, or application scope (servletContext) if it is to be shared across the entire application.
 
Nikhil Muskur
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks .....


i going to handle HTML in JSP in my next project .........but first i am trying it by using servlets ........so please guide me how to put the variable in session scope
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65335
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the setAttribute() method of the session.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic