这里我想使用RequestDispatcher从servlet调用jsp页面,问题是在jsp代码中调用java代码很好,问题是html代码不起作用
这是代码:
重定向Servlet.java:
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
System.out.println("calling doPost() ");
response.setHeader("Pragma", "No-cache");
response.setHeader("Cache-Control","no-store"); //HTTP 1.1
response.setDateHeader("Expires", 0);
response.setHeader("Cache-Control", "no-cache");
response.setContentType("text/html;charset=WINDOWS-1256");
String action=request.getParameter("action");
System.out.println(action);
if(action.equals("reports")){
System.out.println("inside reports");
//Getting values from Reports_arb.jsp
String Fromdate=request.getParameter("FD");
String Todate=request.getParameter("TD");
String status=request.getParameter("actionid");
String usercode=request.getParameter("usercode");
//placing given values in a session
request.setAttribute("FD", Fromdate);
request.setAttribute("TD", Todate);
request.setAttribute("actionid", status);
request.setAttribute("usercode", usercode);
//Redirecting to showReport_arb.jsp
//response.sendRedirect("showReport_arb.jsp");
ServletContext sc = getServletContext();
sc.getRequestDispatcher("/showReport_arb.jsp").forward(request, response);
}
showReportt_arb.jsp:
<HTML dir="rtl">
<HEAD>
<%@ page
language="java" import="java.sql.*"
contentType="text/html; charset=WINDOWS-1256"
pageEncoding="WINDOWS-1256"
isThreadSafe="true"
autoFlush="true"
import ="com.iton.eoffice.WorkflowManagement.*,com.iton.eoffice.contentmanager.*,com.iton.eoffice.authentica tion.*,com.iton.eoffice.*"
import ="java.sql.*,java.util.GregorianCalendar,java.util.Calendar,java.util.Vector,java.text.DateFormat,jav a.text.SimpleDateFormat"
%>
<%
response.setHeader("Pragma", "No-cache");
response.setHeader("Cache-Control","no-store"); //HTTP 1.1
response.setDateHeader("Expires", 0);
response.setHeader("Cache-Control", "no-cache");
%>
...
...
<script language="JavaScript">
function formatTable(oTable)
{
var rows=document.all(oTable).rows;
for(var i=1;i<rows.length;i++)
{
if(i%2==0)
{
for(var j=0;j<rows[i].cells.length;j++)
{
rows[i].cells[j].style.backgroundColor = "#FFFFFF";
rows[i].cells[j].style.borderTop="1 solid #FFFFFF";
rows[i].cells[j].style.borderBottom="1 solid #FFFFFF";
rows[i].cells[j].style.color = "#000000";
}
}
...
...
</script>
....
<%
...
System.out.println("From Date is"+FD);
out.println("welcome to showreports_arb.jsp");
String dtArray[]=FD.split("-");
FD=dtArray[1]+"-"+dtArray[0]+"-"+dtArray[2];....
.....
%>
.....
.....
......
<TABLE align="center">
<TR>
<TD class="set"><input type="button" class="SETARB" value="ØÈÇÚÉ ÇáÊÞÑíÑ" style="width:80px" onclick="printPage()"></TD>
<TD class="set"><input type="button" class="SETARB" value="ÎÑæÌ" style="width:80px" onclick="closePage()"></TD>
</TR>
</TABLE>
<TABLE width="100%" style="border:0px solid #BFBDBA;text-align:center;" align="center">
......
...
..
</html>
在上面的逻辑中,java代码显示在服务器控制台中,但没有显示html代码。请帮我解决这个问题