Hello Forum,
I've another question. I'am writing an web application with servlets and jsp. Some of my servlets don't work because they return (or write out) no html rather then jsp content. And this jsp stuff will not be parsed. Maybe a little bit strange thats why here an example
This is the processRequest Method in my Servlet (will be called from doGet or doPost)
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
try {
out.println("<% String browser = request.getHeader(\"User-Agent\");%>" +
"<davisjsp:tree level=\"-1\" text=\"\" script=\"true\" browser=\"<%=browser%>\" />" +
"<davisjsp:tree level=\"0\" text=\"Golf\" icon=\"project.png\" leaf=\"false\">" +
"<davisjsp:tree level=\"1\" text=\"UP1\" icon=\"project.png\" leaf=\"false\" style=\"WIN\">" +
"<davisjsp:tree level=\"2\" text=\"Admin\" icon=\"admin.png\" leaf=\"true\" />" +
"<davisjsp:tree level=\"2\" text=\"Konstrukteur\" icon=\"konstrukteur.png\" leaf=\"true\" />" +
"</davisjsp:tree>" +
"<davisjsp:tree level=\"1\" text=\"UP2\" icon=\"project.png\" leaf=\"false\">" +
"<davisjsp:tree level=\"2\" text=\"Admin\" icon=\"admin.png\" leaf=\"true\" />" +
"</davisjsp:tree>" +
"</davisjsp:tree>");
} finally {
out.close();
}
}
Like you can see above, there are some additonal taglib used.
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %>
<%@ taglib uri="./include/davis-tags.tld" prefix="davisjsp" %>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<link href="css/layout.css" type="text/css" rel="stylesheet">
<title>AIS DCL</title>
</head>
<body>
<tiles:insertDefinition name="aisdcl.stdView" />
<div id="content" align="left">
<jsp:include page = "projectDetails" flush = "true" >
<jsp:param name = "project" value = "<%=request.getParameter("project")%>"/>
</jsp:include>
</div>
<tiles:insertDefinition name="aisdcl.stdViewLast" />
</body>
</html>
Here I include the servlet and passing a parameter.
And this is the html code from the shown page which the servlet procuded
<div id="content" align="left">
<% String browser = request.getHeader("User-Agent");%>
<davisjsp:tree level="-1" text="" script="true" browser="<%=browser%>" />
<davisjsp:tree level="0" text="Golf" icon="project.png" leaf="false">
<davisjsp:tree level="1" text="UP1" icon="project.png" leaf="false" style="WIN">
<davisjsp:tree level="2" text="Admin" icon="admin.png" leaf="true" />
<davisjsp:tree level="2" text="Konstrukteur" icon="konstrukteur.png" leaf="true" />
</davisjsp:tree>
<davisjsp:tree level="1" text="UP2" icon="project.png" leaf="false">
<davisjsp:tree level="2" text="Admin" icon="admin.png" leaf="true" /></davisjsp:tree>
</davisjsp:tree>
Now my question. How can I use some jsp notation in my servlet whichs output will be parsed as jsp. I hope you understand me. I want that the servlet output is parsed again and not only written out. I could ask in an other way. How can I use taglibs in servlets. I hope you understand and will answer me soon.