我使用此代码进行用户登录表单问题是我可以从Internet Explorer登录但是当我从Firefox登录时,相同的代码会在屏幕上打印HTML代码版本。
此代码在登录后打印待处理列表:
<%@ page language = "java" import="java.util.Iterator" import="java.util.ArrayList" import="java.lang.*" contentType = "text/html; charset = ISO-8859-1"
%>
<%@ page errorPage="/error.jsp" %>
<%
response.setHeader("Pragma", "no-cache");
response.setHeader("Cache-Control", "no-store");
response.setHeader("Expires", "0");
response.setDateHeader("Expires", -1);
//session = request.getSession(false);
// session.invalidate();
// session = request.getSession(true);
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>All Pending List </title>
<style type="text/css">
<!--
@import"Image/cssmenuvertical.css";
-->
</style>
<meta http-equiv="pragma" content="no-cache"/>
<meta http-equiv="cache-control" content="no-cache"/>
<meta http-equiv="expires" content="0"/>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3"/>
<meta http-equiv="description" content="This is my page"/>
<script language="JavaScript" type="text/JavaScript">
function goToURL()
{
window.location="logout.jsp";
}
function bck()
{
window.history.forward();
}
setTimeout("bck()",0);
</script>
<title>All Pending Details</title>
</head>
<body bgcolor="lightblue">
<% String val="for upload";
session.setAttribute("val", val);
%>
<%
if (session.getAttribute("aa") != null) {
%>
<%
String findval = "find validation";
session.setAttribute("findval", findval);%>
<form id="form_id" action="" method="" >
<table id='table1' align="center" >
<tr>
<td style="background-image: url(Image/header.jpg); width: 800px; height: 40px" color="lightblue"></td>
</tr>
<tr>
<td>
<ul id="navmenu">
<li><a href="#">Find ></a>
<ul>
<li><a href="Find_ip.jsp">By IP </a></li>
<li><a href="find_mac.jsp">By Mac Address </a></li>
<li><a href="find_date.jsp">By Date </a></li>
<li><a href="find_email.jsp">By Email </a></li>
<li><a href="find_approve">By Approved </a></li>
<li><a href="find_remove">By Removed </a></li>
<li><a href="find_reg.jsp">By Registration ID</a></li>
</ul>
</li>
<li><a href="AlluploadedForms">| Uploaded Forms ></a></li>
<li> <a href="logout.jsp">| Logout ></a>
</li>
</ul>
</td>
</tr>
</table><br/>
<center>
<FONT COLOR="#0000FF" size="4"><b>All Pending List</b></FONT>
<br/>
<br/>
</center>
<center>
<TABLE cellpadding="15" border="1" style="background-color: #C2DFFF">
<th ><FONT COLOR="#0000FF">Registration NO.</FONT></th>
<th><FONT COLOR="#0000FF">Administrator Name</FONT></th>
<th><FONT COLOR="#0000FF"> Email</FONT></th>
<th><FONT COLOR="#0000FF"> Division Name</FONT></th>
<th><FONT COLOR="#0000FF"> Registration Date</FONT></th>
<%
ArrayList all = (ArrayList) session.getAttribute("values");
Iterator i = all.iterator();
while (i.hasNext()) {
String t = (String) i.next();
out.println(t);
}
%>
</TABLE>
<table><tr><td>
<input type="button" name="logout" value="Logout" onclick="goToURL();"/></td></tr></table>
<%} else {
response.sendRedirect("logout.jsp");
}%>
</center>
</form>
<center><FONT COLOR="#0000FF"> Government Of India<br/>
Ministry Of Communications and Information Technology<br/>
Department of Information Technology </FONT></center>
</body>
从Firefox登录该页面后
答案 0 :(得分:1)
当内容被解释为text/plain
而不是text/html
时,就会发生这种情况。这只能表示HTTP响应Content-Type
已设置为text/plain
,或已损坏或丢失。
使用HTTP流量检查器检查HTTP响应标头。如果您安装了Firebug,请按F12并选中 Net 标签。 Content-Type
标题必须至少说text/html
。默认情况下已经是这种情况。也许你有一些Filter
做错了。
无关,与在问题中最初发布的JSP代码中指定响应字符编码不一致。您在HTTP响应标头中指定了ISO-8859-1,并且您在HTML元头中指定了UTF-8。这毫无意义。但是,这不应该引起这种问题。
顺便说一下,&#34;信息技术部&#34;然后那个写旧的学校风格的JSP充满了被弃用的HTML元素和糟糕的做法......?这是一个业余爱好网站还是什么?
答案 1 :(得分:-1)
我尝试登录并且可以看到代码正常工作,根据此图片获得管理员无效错误: