
I am using this code to make user login form the issue is I am able to login from Internet Explorer but when I login from Firefox this same code prints the HTML version of the code on the screen.
This code prints the pending list after login:
<%@ 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>
After login on that page from Firefox
That will happen when the content is been interpreted as
text/plaininstead of astext/html. That can only mean that the HTTP responseContent-Typeis been set totext/plain, or is broken, or is missing.Check the HTTP response headers with a HTTP traffic checker. If you have Firebug installed, then press F12 and check Net tab. The
Content-Typeheader must say at leasttext/html. This is by default already the case. Perhaps you’ve someFilterwhich is doing its job wrong.Unrelated to the concrete problem, you are not consistent with specifying the response character encoding in the JSP code as initially posted in your question. You’re specifying ISO-8859-1 in the HTTP response header and you’re specifying UTF-8 in the HTML meta head. This makes no sense. This should however not cause this kind of problem.
By the way, “Department of Information Technology” and then that oldschool style of writing JSPs full of deprecated HTML elements and poor practices…? Is this a hobby site or something?