This works to return a string:
import javax.servlet.http.*;
@SuppressWarnings("serial")
public class MonkeyServlet extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
resp.setContentType("text/plain");
resp.getWriter().println("got this far");
}
}
But I can't get it to return an html document. This doesn't work:
import javax.servlet.http.*;
@SuppressWarnings("serial")
public class BlotServlet extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
resp.setContentType("text/html");
resp.getWriter().println("html/mypage.html");
}
}
Sorry for being noob!
EDIT:
I already have the html in separate documents. So I need to either return the document, or read/parse it somehow, so I'm not just retyping all the html...
EDIT:
I have this in my web.xml
<servlet>
<servlet-name>Monkey</servlet-name>
<servlet-class>com.self.edu.MonkeyServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Monkey</servlet-name>
<url-pattern>/monkey</url-pattern>
</servlet-mapping>
Is there something else I can put in there so it just returns a file, like...
<servlet-mapping>
<servlet-name>Monkey</servlet-name>
<file-to-return>blot.html</file-to-return>
</servlet-mapping>