I have an application which has a jsp file. I need to include another jsp file which is in tomcat properties folder in this jsp file. I tried several methods but everytime I get the error as the file cannot be found.
Jsp in application:
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page language="java" isErrorPage="false"%>
<%@ page import="java.io.*,java.util.*" %>
<%
String brandFile="/home/tomcat/properties/utransfer/brand/brand_1.jsp";
request.getRequestDispatcher(brandFile).include(request,response);
%>
/home/tomcat/properties/utransfer/brand/brand_1.jsp:
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
Hello
</html>
The error I get is :
Caused by: javax.servlet.ServletException: File [/home/tomcat/properties/utransfer/brand/brand_1.jsp] not found
at org.apache.jasper.servlet.JspServlet.handleMissingResource(JspServlet.java:408)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:375)
In the application jsp I also tried the following:
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page language="java" isErrorPage="false"%>
<%@ page import="java.io.*,java.util.*" %>
<%!
String brandFile="/home/tomcat/properties/utransfer/brand/brand_1.jsp";
%>
<jsp:include page="<%=brandFile %>" />
Also tried,
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page language="java" isErrorPage="false"%>
<%@ page import="java.io.*,java.util.*" %>
<%@ include file="/home/tomcat/properties/utransfer/brand/brand_1.jsp" %>
Also tried,
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page language="java" isErrorPage="false"%>
<%@ page import="java.io.*,java.util.*" %>
<%@ taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "c" %>
<c:import var = "data" url = "/home/tomcat/properties/utransfer/brand/brand_1.jsp"/>
<c:out value = "${data}"/>
I tried the following code:
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page language="java" isErrorPage="false"%>
<%@ page import="java.io.*,java.util.*" %>
<%@ taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "c" %>
<c:import url = "http://serverName/utransfer_static/brand/brand_1.jsp"/>
Getting the following error:
Caused by: java.io.IOException: Server returned HTTP response code: 500 for URL: http://serverName/utransfer_static/brand/brand_1.jsp
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1894)
In browser, if I directly give this URL (http://serverName/utransfer_static/brand/brand_1.jsp), I am getting the contents.
Please advice on what can be done. Thanks.