Pregunta

My file structure in eclipse is

src/
   com.test/
            Servlet1.java

I am trying to refer to it in JSP using

<jsp:include page="com.test/Servlet1"></jsp:include>

It gives me the File not found error.

Here com.test is the package name and Servlet1.java is the servlet file I want to use.

¿Fue útil?

Solución

The usage of <jsp:include> is

<jsp:include page="{relativeURL | <%= expression%>}" flush="true" />

So page attribute should be a relative URL rather than a Servlet file path.

For example, if you configure your Servlet1 as:

<servlet>   
    <servlet-name>Servlet1</servlet-name>   
    <servlet-class>com.test.Servlet1</servlet-class>   
</servlet>   
<servlet-mapping>   
    <servlet-name>Servlet1</servlet-name>   
    <url-pattern>/test</url-pattern>   
</servlet-mapping> 

Then your jsp:include tag should be:

<jsp:include page="/test"></jsp:include>

Otros consejos

I believe com.test makes a new folder named "test" inside a folder named "com" which means the path should be com/test/Servlet1 instead of your com.test, not completely sure tho

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top