Can I know how do I call a method in a JSP page when the method itself is in a servlet?
I have a SQL query in the servlet and I would like to call it in the JSP page. Can someone tell me how is it done?
[CODE] private void getFullName(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {response.setContentType(CONTENT_TYPE);
String username = “test”;
String password = “test”;
String thinConn = “jdbc:oracle:thin:@172.20.134.87:1521:ORCL”;
Connection conn;
Statement stm;
ResultSet rs;
String baseQuery =”SELECT FIRST_NAME||’ ‘||LAST_NAME AS FULLNAME FROM STAFF”;
try {
conn = DriverManager.getConnection(thinConn,username,password);
stm = conn.createStatement();
rs = stm.executeQuery(baseQuery);
while (rs.next()) {
String fullName = rs.getString(“FULLNAME”);
}
conn.close();
} catch (SQLException e) {
}
}
This is the codes that I would like to call in the JSP page.
[CODE]function searchStaff()
{
//search by first name
var name=document.getElementById(‘staffname’).value;
//search by last name
var name2=document.getElementById(‘staffname2’).value;
var themebasedfoi=mapview.getThemeBasedFOI(“themebasedfoi1”);
var themebasedfoi2=mapview.getThemeBasedFOI(“themebasedfoi2”);
if(id==3){
if(themebasedfoi==null)
{
themebasedfoi = new MVThemeBasedFOI(‘themebasedfoi1′,’TEST.search3’);
themebasedfoi.setQueryParameters(name,name2);
themebasedfoi.setBringToTopOnMouseOver(true);
mapview.addThemeBasedFOI(themebasedfoi);
}
else
{
themebasedfoi.setQueryParameters(name,name2);
themebasedfoi.setBringToTopOnMouseOver(true);
themebasedfoi.refresh();
}
}
else if(id==4){
if(themebasedfoi2==null)
{
themebasedfoi2 = new MVThemeBasedFOI(‘themebasedfoi2′,’TEST.search4’);
themebasedfoi2.setQueryParameters(name, name2);
themebasedfoi2.setBringToTopOnMouseOver(true);
mapview.addThemeBasedFOI(themebasedfoi2);
}
else
{
themebasedfoi2.setQueryParameters(name, name2);
themebasedfoi2.setBringToTopOnMouseOver(true);
themebasedfoi2.refresh();
}
}
}
This is the function that I would like to place the query in which is the JSP page. Any help would be much appreciated.