【发布时间】:2016-06-08 16:25:50
【问题描述】:
<%--
Document : Profile
Created on : Jun 5, 2016, 1:28:02 AM
Author : User
--%>
<%@page import="ServletHolder.Database"%>
<%@page import="java.sql.*"%>
<%@page import="java.io.*"%>
<%
response.setHeader("Cache-Control","no-cache");
response.setHeader("Cache-Control","no-store");
response.setDateHeader("Expires", 0);
response.setHeader("Pragma","no-cache");
HttpSession s=request.getSession();
try{
String a=(String)s.getAttribute("email");
String b=(String)s.getAttribute("password");
if((a.equals("a") && b.equals("b"))){
}else{
response.sendRedirect("index.jsp");
}
}catch(Exception e){
response.sendRedirect("index.jsp");
}
Connection con=Database.getConnection();
PreparedStatement pst;
ResultSet rs;
String c="shakil123@gmail.com";
String ah="";
Blob img;
byte[] imgdata=null;
try{
String al="select * from `uploadpic` where `email`='"+c+"'";
pst=con.prepareStatement(al);
rs=pst.executeQuery();
if(rs.next()){
ah=rs.getString("email");
img=rs.getBlob("pic");
imgdata=img.getBytes(1, (int)img.length());
}
}catch(Exception e){
ah=e.toString();
}
response.setContentType("image/gif");
OutputStream o = response.getOutputStream();
// o.write(imgdata);
// o.flush();
// o.close();
%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body><!-- onload="noBack()" onpageshow="noBack()">-->
<h1>Profile</h1>
<div span="12">
<div sapan="9">
<p><strong> Hello User Welcome!!!</strong></p>
<img src="scrum-chart.jpg" alt="Mountain View" style="width:200px;"><br>
<p><%=ah%><p>
<img src="<%
o.write(imgdata);
o.flush();
o.close();
%>" alt="Profile Picture" width="200" title="Profile Picture">
</div>
<div sapan="3">
<p><strong> Advertisement</strong></p>
</div>
</div>
<a href="Editprofile.jsp"> Edit Profile</a><br>
<form action="Logout" method="post">
<input type="submit" value="Logout">
</form>
</body>
</html>
但问题是,当我访问我的个人资料时,它只显示数据库中的图像。只有检索到的图像显示在页面中,但其他代码不起作用,其他属性未显示在页面中.. ..
【问题讨论】:
-
你能clarify你对问题的解释以及预期与实际结果吗?我暂时不明白。
-
当我加载这个页面时,这个页面只包含来自数据库的图像。但是没有添加更多的东西,比如段落,另一张图片,但这个页面没有显示。