|
Home > Archive > EAserver > September 2005 > getContextPath()
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
|
| Hi,
On my JSP page I make a href call to open another page that
has the hardcoded server name as part of the URL. To remove
the hardcoded reference I am trying
<%=request.getContextPath()%> but this is failing. I get an
error message that the URL is not found. Is there anything
incorrect in using the <%=request.getContextPath()%>.
The code snippet is below.
Harcoded Server reference
---------------------------------
parent.frame_3.document.location.href="http://dbsnaxpws1004:8080/datamanager/tabledata.jsp"
getContextPath()
----------------------
parent.frame_3.document.location.href="<%=request.getContextPath()%>/datamanager/tabledata.jsp"
Any inputs is highly appreciated.
Regards,
Ravi
| |
| Mark Maslow 2005-09-02, 8:25 pm |
| You can form the complete URL as follows:
<%=request.getScheme()+"://"+request.getServerName()+":"+request. getServerPort()+requ
est.getContextPath()%>/datamanager/tabledata.jsp
<Ravi> wrote in message news:431892f9.20c9.1681692777@sybase.com...
> Hi,
>
> On my JSP page I make a href call to open another page that
> has the hardcoded server name as part of the URL. To remove
> the hardcoded reference I am trying
> <%=request.getContextPath()%> but this is failing. I get an
> error message that the URL is not found. Is there anything
> incorrect in using the <%=request.getContextPath()%>.
>
> The code snippet is below.
>
> Harcoded Server reference
> ---------------------------------
> parent.frame_3.document.location.href="http://dbsnaxpws1004:8080/datamanager/tabledata.jsp"
>
> getContextPath()
> ----------------------
> parent.frame_3.document.location.href="<%=request.getContextPath()%>/datamanager/tabledata.jsp"
>
> Any inputs is highly appreciated.
>
> Regards,
>
> Ravi
| |
|
| Hi Mark,
Thanks for the help.
I get "Object expected ;" JS error when I create the URL as
suggested. However I tried building by getting the
individual parameter values into local JS variables and
concatenate them to one url string which works. I am not
sure why this could happen.
URL String via JS variables
--------------------------------
var js_getscheme = "<%=request.getScheme() %>";
var js_getsrvname = "<%=request.getServerName() %>";
var js_getsrvport = "<%=request.getServerPort() %>";
var js_getcontextpath = "<%=request.getContextPath() %>";
var js_url =
js_getscheme+"://"+js_getsrvname+":" +js_getsrvport+js_ge
tcontextpath+"/tabledata.jsp?dmtarget="
Thanks and regards,
Ravi
> You can form the complete URL as follows:
>
> <%=request.getScheme()+"://"+request.getServerName()+":"+r
> equest. getServerPort()+requ
est.getContextPath()%>/datamana
> ger/tabledata.jsp
>
>
> <Ravi> wrote in message
> news:431892f9.20c9.1681692777@sybase.com...
>
> <%=request.getContextPath()%>. >
> parent.frame_3.document.location.href="http://dbsnaxpws100
> 4:8080/datamanager/tabledata.jsp" >
> parent.frame_3.document.location.href="<%=request.getConte
> xtPath()%>/datamanager/tabledata.jsp" >
>
>
| |
| Carson Hager 2005-09-02, 8:25 pm |
| You're confusing the use of getContextPath(). It returns that root web
application context. In your case, getContextPath() will return
"/datamanager", not the host name.
Carson
____________________
____________________
____
Carson Hager
Cynergy Systems, Inc.
http://www.cynergysystems.com
Email: carson. hager@cynergysystems
.com
Office: 866-CYNERGY ext. 89
Mobile: 1.703.489.6466
Take PowerBuilder to the Web with EAF 4.0
http://www.cynergysystems.com/public/products/eaf
<Ravi> wrote in message news:431892f9.20c9.1681692777@sybase.com...
> Hi,
>
> On my JSP page I make a href call to open another page that
> has the hardcoded server name as part of the URL. To remove
> the hardcoded reference I am trying
> <%=request.getContextPath()%> but this is failing. I get an
> error message that the URL is not found. Is there anything
> incorrect in using the <%=request.getContextPath()%>.
>
> The code snippet is below.
>
> Harcoded Server reference
> ---------------------------------
> parent.frame_3.document.location.href="http://dbsnaxpws1004:8080/datamanager/tabledata.jsp"
>
> getContextPath()
> ----------------------
> parent.frame_3.document.location.href="<%=request.getContextPath()%>/datamanager/tabledata.jsp"
>
> Any inputs is highly appreciated.
>
> Regards,
>
> Ravi
| |
| Adam Simmonds [TeamSybase] 2005-09-02, 8:25 pm |
| Ravi wrote:
> Hi Mark,
>
> Thanks for the help.
>
> I get "Object expected ;" JS error when I create the URL as
> suggested. However I tried building by getting the
> individual parameter values into local JS variables and
> concatenate them to one url string which works. I am not
> sure why this could happen.
>
> URL String via JS variables
> --------------------------------
> var js_getscheme = "<%=request.getScheme() %>";
> var js_getsrvname = "<%=request.getServerName() %>";
> var js_getsrvport = "<%=request.getServerPort() %>";
> var js_getcontextpath = "<%=request.getContextPath() %>";
> var js_url =
> js_getscheme+"://"+js_getsrvname+":" +js_getsrvport+js_ge
tcontextpath+"/tabledata.jsp?dmtarget="
I may be wrong but you are most likely going to have to
write out the JavaScript in your jsp code.
<javascript type=text/javascript>
<%
out.println("var js_getscheme='"+request.getScheme()+"';");
%>
</javascript>
I havent my code on hand but I have done similar in the past.
a.
[color=darkred]
>
> Thanks and regards,
>
> Ravi
>
>
>
>
| |
| Rahul Jain 2005-09-03, 3:24 am |
| Do you have a web app created? In other words, is datamanager a
webapplication? I am pretty sure I ran this code of yours when we last
talked about it. Wasn't I the one to suggest using getContextPath :)?
R
<Ravi> wrote in message news:431892f9.20c9.1681692777@sybase.com...
> Hi,
>
> On my JSP page I make a href call to open another page that
> has the hardcoded server name as part of the URL. To remove
> the hardcoded reference I am trying
> <%=request.getContextPath()%> but this is failing. I get an
> error message that the URL is not found. Is there anything
> incorrect in using the <%=request.getContextPath()%>.
>
> The code snippet is below.
>
> Harcoded Server reference
> ---------------------------------
> parent.frame_3.document.location.href="http://dbsnaxpws1004:8080/datamanager/tabledata.jsp"
>
> getContextPath()
> ----------------------
> parent.frame_3.document.location.href="<%=request.getContextPath()%>/datamanager/tabledata.jsp"
>
> Any inputs is highly appreciated.
>
> Regards,
>
> Ravi
|
|
|
|
|