0

as i use my

<a href="${pageContext.request.contextPath}/rest/hello">Hello</a>

my url becomes

http://localhost:8080/spring-rest-demo/$%7BpageContext.request.contextPath%7D/rest/hello

why is this happening

i have javax.servlet-api and javax.servlet.jsp-api dependency in my pom file as well

and it is a jsp file not html

Minar Mahmud
  • 2,577
  • 6
  • 20
  • 32
mimoh
  • 11
  • 5

2 Answers2

0

Expressions like ${pageContext.request.contextPath} cannot be used in a plain HTML file, they must be used inside a JSP file. I suggest you start by reading a few tutorials about Java servlets and JSP.

You can simply ignore it.

If you really want to redirect it to another page. So, you need to add JSTL Dependency to use the expression language.

I recommend you to use Thymeleaf which is easy to use and you can easily play with the controller's

kkrkuldeep
  • 83
  • 5
  • it is a jsp file not plain html file – mimoh Jun 17 '20 at 15:03
  • can u share your pom file and error logs might your dependency is too old https://stackoverflow.com/questions/25360722/java-lang-classnotfoundexception-org-apache-jsp-web-002dinf-pages-landingpage-j It helps you – kkrkuldeep Jun 18 '20 at 04:42
0

Firstly, classpath is a completely different thing. What you wanted to mean is Context Path.

It seems that you don't have Expression Language (EL) in your classpath. Add this to your dependencies:

<dependency>
    <groupId>javax.el</groupId>
    <artifactId>javax.el-api</artifactId>
    <version>3.0.0</version>
</dependency>

This should fix the issue with resolving ${pageContext.request.contextPath}.

Suggestion

Use url tag from JSTL. Or, url tag from Spring Framework.

Minar Mahmud
  • 2,577
  • 6
  • 20
  • 32