• Post Reply Bookmark Topic Watch Topic
  • New Topic

getContextPath not applicable to HttpSession  RSS feed

 
Himai Minh
Ranch Hand
Posts: 1572
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On p. 222 of Head First Servlet, only HttpServletRequest can have getContextPath () (the request URI that indicates the context).


According to p.198,
a session is an object used to maintain conversational state with a client
.
Why HttpSession does not have this method ?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66260
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why would it?

(Hint: you can get it from other information you can get from the session.)
 
Himai Minh
Ranch Hand
Posts: 1572
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it because each request within a session has different context path ?
In the other words, a session may have different context path for different requests?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66260
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. The context path is fixed for the application.

The reason is, as I hinted, it's already available from information that the session returns so a method would be redundant. Look at the javadoc carefully (and deeply).
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!