David
David

Reputation: 299

Struts 2 Include Tag

I have two JSP files in the same folder on a java webapp. Let's call them index.jsp and myInclude.jsp. I want to include myInclude.jsp inside index.jsp. The webapp is not being served in the ROOT uri, but out of a separate webapp (such as /adminWebapp/).

In index.jsp, I have the following:

<s:include value="myInclude.jsp" />

When I try to access index.jsp, Struts throws the following exception:

Exception thrown during include of myInclude.jsp
java.io.FileNotFoundException: /myInclude.jsp

The trouble is that Struts 2's include tag added a "/" in front of the URL to the included file. If Struts 2 wants to use an absolute path (instead of relative), it would need to call /adminWebapp/myInclude.jsp. Is there any option which could fix the s:include tag? I'm hoping to avoid hard-coding the /adminWebapp into the link in case we ever move the webapp.

Upvotes: 2

Views: 1871

Answers (1)

Muhammad Imran Tariq
Muhammad Imran Tariq

Reputation: 23352

Try it with include directive

<%@ include file = "xxx" %>

Upvotes: 1

Related Questions