I've some question about jsp,
I've some method let say the name of the method is getStaffDetail and were written in staffDetail.jsp file below code in staffDetail.jsp
<%!
public StaffDetails getStaffDetail(int staffId) throws SQLException{
//Request to db
//process the result set
//return StaffDetail
}
%>
and this method were use in personPage.jsp file by calling it using include directive
personPage.jsp
<%@ include file = "/path/staffDetail.jsp">
<%
StaffDetails sd = getStaffDetail(1234);
String stafName = sd.getStfName();
String stfAddress = sd.getStfAddress();
//and the rest...
%>
Or should I write this code in java class for example StaffDetail.class
package packageName
import DBAccess;
public class StaffDetail{
//Request to db
//process the result set
//Setter n getter in this class
}
And in the personPage.jsp
<@ page import = "package.StaffDetail">
<%
StaffDetail sdInClass = new StaffDetail();//
sdInClass.getStfName();
sdInClass.getStfAddress();
%>
The code is quite same the only difference is instead of putting the method in the jsp file, I put in the class
I would like to ask which once better in performance.
p/s I know that we as a java web programmer are discourage to use scriplet in jsp file, but for some reason I can't convert all the scriplet to EL. The least I can do is convert the method into class file. Sorry I'm new in java programming