Я пытаюсь создать профиль для текущего пользователя, вошедшего в систему, я могу получить все данные и отобразить их на странице jsp (profile.jsp), как мне также отобразить конкретное изображение зарегистрированного пользователя? ? help pls
sample_crud.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@page import="dao.*,conn.*,tables.*,java.util.*,java.sql.*"%>
<%
List<user> list=dbdao.getAllRecords();
request.setAttribute("list",list);
List<user> total=dbdao.getTotalAcc();
request.setAttribute("total",total);
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
PreparedStatement ps = null;
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%
String username=(String)session.getAttribute("username");
//redirect user to login page if not logged in
if(username==null){
response.sendRedirect("login.jsp");
}
%>
<h1 align="center">CREATE, READ, UPDATE and DELETE LECTURE</h1>
<a href="logout.jsp"> Logout</a>
<a href="profile.jsp?username=${username}"> profile</a>
<p>Welcome, <%=session.getAttribute("username")%></p>
<form action="savedis" method="post" enctype="multipart/form-data">
<input type="text" name="fname" placeholder="First Name">
<input type="text" name="lname" placeholder="Last Name">
<input type="text" name="username" placeholder="Usernamee">
<input type="password" name="pass" placeholder="Password">
<input type="file" name="photo">
<button type="submit">SUbmit </button>
</form>
<div>
<c:forEach items="${total}" var="t">
${t.getacc_id()}
</c:forEach>
Totals </div>
<table border="1">
<tr>
<th>ID</th>
<th>Full Name</th>
<th>Country</th>
<th>user</th>
<th>pass</th>
<th>Image</th>
<th>edit</th>
<th>delete</th>
</tr>
<c:forEach items="${list}" var="st">
<tr>
<td>${st.getacc_id()}</td>
<td>${st.getfname()}</td>
<td>${st.getlname()}</td>
<td>${st.getusername()}</td>
<td>${st.getpass()}</td>
<td><a href="view.jsp?id=${getacc_id}">view</a></td>
<td><a href="indexUpdate.jsp?id=${st.getacc_id()}">Edit</a></td>
<td><a href="deletedis.jsp?acc_id=${st.getacc_id()}"> Delete</a></td>
</tr>
</c:forEach>
</table>
</body>
</html>
profile.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@page import="dao.*,conn.*,tables.*,java.util.*,java.sql.*"%>
<%
String username= request.getParameter("username");
user st=dbdao.getRecordByUser(username);
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>ProfileS</title>
</head>
<body>
<%=st.getacc_id()%><br>
<%=st.getfname()%><br>
<%=st.getlname()%><br>
<%=st.getusername()%><br>
<%=st.getpass()%><br>
<%=st.getphoto()%><br><img src="imgRet.jsp?id=${st.getacc_id()}"
alt="Image"><br>
<a href="sample_crud.jsp">back</a>
</body>
</html>
imgRet.jsp
<%@page import="java.io.*,java.sql.*,java.util.*"%>
<%@page import="dao.*,conn.*,tables.*"%>
<%@page import="org.apache.commons.fileupload.*"%>
<%@page import="org.apache.commons.io.output.*"%>
<%@page import="org.apache.commons.fileupload.servlet.*"%>
<%@page import="org.apache.commons.fileupload.disk.*"%>
<%@page trimDirectiveWhitespaces="true" %>
<%
Blob image = null;
byte[] imgData = null ;
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
String j=request.getParameter("id");
int i=Integer.parseInt(j);
try{
con=dbconn.getConnection();
stmt = con.createStatement();
rs = stmt.executeQuery("select photo from sc_accounts
where acc_id="+i);
OutputStream o = response.getOutputStream();
if(rs.next()) {
image = rs.getBlob(1);
imgData = image.getBytes(1,
(int)image.length());
response.setContentType("image/jpg");
o.write(imgData);
o.flush();
o.close();
return;
}
} catch (Exception e) {out.println("Image Display Error=" + e.getMessage());}
%>
я ожидал показатьтолько конкретное изображение пользователя, но я знаю только показ всех изображений в базе данных в данной таблице.