| Author |
problem with request.getContextPath()
|
Srinivas Kalvala
Ranch Hand
Joined: Oct 20, 2005
Posts: 257
|
|
Hello, One of my friend told that, the JSP page will not be traslated if following line is included in JSP. <%=request.getContextPath()%> is he correct ? or any other problem is associated with this ?
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56540
|
|
Did you try it? Did you ask him what the issue might be? How else, at least using scriplets, would you expect to obtain the context path?
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Srinivas Kalvala
Ranch Hand
Joined: Oct 20, 2005
Posts: 257
|
|
Originally posted by Bear Bibeault: Did you try it? Did you ask him what the issue might be? How else, at least using scriplets, would you expect to obtain the context path?
Some of the forums says, the JSP page will be translated every time, if it see that method() ... Is it true ? [ February 09, 2007: Message edited by: Srinivas Kalvala ]
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56540
|
|
You can easily test that as well. But as an academic exercise, why would you (or anyone) believe that just calling a method, just like any other method, would trigger a retranslation?
|
 |
Srinivas Kalvala
Ranch Hand
Joined: Oct 20, 2005
Posts: 257
|
|
Can you tell me, how can we test that one ? Or Can you tell me, the problems that can occur with the use of request.getContxtPath() in jsp directly ?
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56540
|
|
Originally posted by Srinivas Kalvala: Can you tell me, how can we test that one ? ?
Use the scriptlet expression in a page and see if a new servlet is generated on behalf of the JSP whenever it is accessed. You will find that it will not.
Can you tell me, the problems that can occur with the use of request.getContxtPath() in jsp directly
None. In fact, you must use the context path when creating correct server-relative URLs. Though I do recommend that scriplet expression be avoided under the JSP 2.0 environment in favor of the EL equivalents.
|
 |
 |
|
|
subject: problem with request.getContextPath()
|
|
|