Java – the concept of page path in JSP and Servlet

What's the difference between the two?

In jsp:

${pageContext.request.contextPath}

How do you achieve the same result without expression language and servlet coding?

In the servlet:

request.getServletPath()

If it is encoded in JSP, how to achieve the same result?

Solution

${pagecontext. Request. Contextpath}: returns a part of the request URI indicating the context of the request In fact, it is similar to request Getcontextpath () is exactly the same because ${pagecontext. Request} refers to the HttpServletRequest

For example:

Http: / / local host: 80 / all myapplication / paths / servlets

>${pagecontext. Request. Contextpath} returns / myapplication > request Getservletpath () returns part of the URL of the servlet called by this request, for example, > ${pagecontext. Request. Servletpath} return / path / servlet of / path / Servlet

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>