3

To remove the language toggle from the page view(Comfirmation Page)

I found this code but it doesn't work in Spring MVC

<c:if test="${!fn:contains(pageContext.request.servletPath,'/comfirmation')}">
         //Other Code
</c:if>
  • My actual url is (ShoppingCart.jsp).
  • It is used when /viewCart.htm,/updateCart.htm,/Confirmation.htm,etc.
  • So, the user go to the /Confirmation.htm, it also redirect to the ShoppingCart.jsp but the url path in the browser is /Confirmation.htm.
  • I want to remove the language toggle when call the /Confirmation.htm in the above mention.
Thein
  • 3,940
  • 2
  • 30
  • 34
  • Check out this. http://stackoverflow.com/questions/1256562/java-httpservletrequest-get-url-in-browsers-url-bar – Prasanna Jul 12 '11 at 05:44

2 Answers2

4

Finally, I got it. Here we go

<%
    String url=request.getAttribute("javax.servlet.forward.servlet_path").toString();
    if(url.equals("/Confirmation.htm")){    
%>
     //Language Toggle code
<% } %>

I decided to use this. Another way is that storing url path in session since front controller.

Thein
  • 3,940
  • 2
  • 30
  • 34
1

the pageContext.request.servletPath will give you the path of the jsp (and not the url your browser shows).

The request is forwarded to a controller, which returns a path to a view. The view ist called using a second internal request

James Raitsev
  • 92,517
  • 154
  • 335
  • 470
Michael
  • 79
  • 1