Issue
Currently I am trying to display information from my java servlet over to its related jsp page. However, when I run the program, the expected output of the jsp file is displayed in the servlet directory.
Visually, the Display.jsp page:
And \ServerToRun (The Servlet page that should display a blank screen):
Thus my question is,
Why is the content of /Display.jsp appearing in /ServerToRun?
Here is the code for doPost()
of the ServerToRun class:
protected void doPost(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
CSVFileOperations csvfo = new CSVFileOperations();
String url = "/Display.jsp";
response.setContentType("text/html");
String header = csvfo.getHeaders().remove();
System.out.println(header);
request.setAttribute("header", header);
request.getServletContext().getRequestDispatcher(url).
forward(request, response);
}
And the markup for Display.jsp:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>OTS Grief</title>
</head>
<body>
${header}<br>
Test Why is his showing up in ServerToRun?
</body>
</html>
Any help is appreciated.
Solution
I think I understand your question. You're talking about directories.
In your URL, the path (/Grief_UI/Display.jsp and /Grief_UI/ServletToRun) is not necessary related to folders.
It is a structuring element of the URL. Sometimes you don't even have files that are named like these path elements. The path gets normally processed by a Servlet and the user gets the feeling of using folders, yes, but it is only a description for the localising the resources.
Answered By - Janos Vinceller