cancel
Showing results for 
Search instead for 
Did you mean: 

jsp include

Former Member
0 Kudos

I want to include a JSP from another application. Is this possible?

I have one application called "include" and one application called "myapp". From the /myapp/index.jsp i'm trying to use the tag <jsp:include page="/include/myinclude.jsp" />. Nothing shows for the include and no errors are thrown.

Any help is appreciated.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

hi,

you have to use

<%@include file=="/include/myinclude.jsp" %>

i am not sure but <jsp:include page="/include/myinclude.jsp" /> works for only html pages i.e if you have myinclude.htm then you can use this.

hope this helps, else revert back.

Regards,

Hemendra

Former Member
0 Kudos

I knew about the include file. Unfortuneately that does not solve my problem. I am trying to include a dynamic jsp from another application.

What I don't want to do is build a huge application that includes every JSP that I have built. I have them broken up in subdirectories that are functional specific. I have one directory that hardly ever changes, but is very useful for all applications. These are not static files. They are again dynamic.

Hopefully this can be done.

Former Member
0 Kudos

hi,

you want to call a dynamic jsp i.e. it has some of its functionality.

then in my opinion you should use forward or redirection instead of include. since in case of include tag during server compilation the tag is replaced by the code of that include jsp page.

since your page is dynamic hence it is not getting displayed and neither showing any error.

try using forward tag to the page as:

<jsp:forward page="your_page_loc.jsp" />

and if you want to pass any paramateres then you can pass using: <jsp:forward page="your_page_loc.jsp"> <jsp:param name="username" value="jsmith" /> </jsp:forward>

alternatively you can redirect like:

response.sendRedirect("http://your_path_for_file/filename.jsp ");

OR

You can also physically alter the Location HTTP header attribute, as shown below:

<%

response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);

String newLocn = "/newpath/filename.jsp";

response.setHeader("Location",newLocn);

%>

Hope this may solve your problem,

Regards,

Hemendra