private void show_student_profile(HttpServletRequest request, HttpServletResponse response) throws Exception
{
int _student_id = Integer.parseInt(request.getParameter("s_id"));
Student student = student_db_util.info_load_of_student(_student_id);
request.setAttribute("STUDENT_INFO", student);
RequestDispatcher request_dispatcher = request.getRequestDispatcher("view_student_profile.jsp");
request_dispatcher.forward(request, response);
}
这是view_student_profile.jsp
我想将此JSP作为pdf文件获得,因为它将显示特定学生个人资料的一些基本信息。我尝试使用response.setContentType。但是我不知道我在做什么错。它没有将jsp作为pdf。
<body>
<input type="hidden" name="s_id" value="${STUDENT_INFO._student_id}"/>
<table>
<tbody>
<tr>
<td><label>First name:</label></td>
<td><input type="text" name="s_f_name" value="${STUDENT_INFO._student_first_name}" readonly style="border: 0"/></td>
</tr>
<tr>
<td><label>Last name:</label></td>
<td><input type="text" name="s_l_name" value="${STUDENT_INFO._student_last_name}" readonly style="border: 0"/></td>
</tr>
<tr>
<td><label>Roll No:</label></td>
<td><input type="number" name="s_roll_number" value="${STUDENT_INFO._student_roll_no}" readonly style="border: 0"/></td>
</tr>
<tr>
<td><label>Class:</label></td>
<td><input type="number" name="s_class" value="${STUDENT_INFO._student_class}" readonly style="border: 0"/></td>
</tr>
</tbody>
</table>
</body>