简体   繁体   中英

contextpath is appended

i have created one hyperlink, and by clicking on that i am redirecting the page to another JSP, but i am not getting the correct URL that i am passing, URL is appended with another string and the page is not redirected,

please anybody have any idea about that, help me out

  <td align='<%=lstrColAlign%>' class="<%=tdclass%> Label2"  
   style="<%=rb.getDataStyleString(rvo,data)%>">
   <a  href="#" onclick="JavaScript:window.open( '<%=columnUrl%>','newwindow','top=0, left=0,   
             scrollbars=yes,status=1,resizable=yes,height= (screen.availHeight - 10),
             width= (screen.availWidth-5)')"> <%=rb.getDataValue(data)%></a>
   </font></td>

where i should get

...Project1-context-root/servlet/Reports.controller.ReportController?ActionFlag=get.............

but instead of that i am getting

...Project1-context-root/servlet/servlet/Reports.controller.ReportController?ActionFlag=get.....

so, extra word servlet/ is appended

Relative URL's without a leading slash are relative to the current context. Ie if the current URL in the browser address bar is http://example.com/context/index.jsp and the relative URL to be opened from the current context is context/page.jsp , then the final URL would be http://example.com/context/context/page.jsp .

There are several ways to fix this:

  1. Remove the same context in the relative URL, so that it ends as page.jsp .
  2. Add a leading slash so that it becomes relative to the domain root: /context/page.jsp .
  3. Make it an absolute URL instead: http://example.com/context/page.jsp .
  4. Bring the context of the relative URL one step back: ../context/page.jsp .

It works all the same way as with disk filesystem paths.

It seems like your <%=columnUrl> variable is getting

servlet/Reports.controller.ReportController?ActionFlag=get.....

And from your calling JSP, it's appending context path automatically..

Debug your columnUrl variable first and change that variable value to relative by updating it to ../context/page.jsp should works for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM