- This topic has 6 replies, 2 voices, and was last updated 19 years, 10 months ago by wk3000sg.
-
AuthorPosts
-
wk3000sgMember– Is there any problem with these codes in processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException.
– it seems that it execute the “else” rather than executing the “if(temp…(“select”))” statement when i have a sql query =”select * from Business”.
<–code starts here–>
😀
if(temp.equalsIgnoreCase(“select”)){
data= db.execSelectQuery(request.getParamete(“sqlstatement”));
request.getSession().setAttribute(“data”, data);
request.getRequestDispatcher(“/WEB-INF/pages/DisplayData.jsp”).forward(request, response);}else if ((temp.equalsIgnoreCase(“Update”) || temp.equalsIgnoreCase(“Insert”) || temp.equalsIgnoreCase(“Delete”))){
updatedata= db.execUpdateQuery(request.getParameter(“sqlstatement”));
Integer intobj = new Integer(updatedata);
request.getSession().setAttribute(“intobj”, intobj);
request.getRequestDispatcher(“/WEB-INF/pages/DisplayCUDData.jsp”).forward(request, response);}
else{
request.getRequestDispatcher(“/WEB-INF/pages/NoData.htm”).forward(request, response);
}
}
😕
<—code ends here–>
Riyad KallaMemberI think you need to give more background into the code that executes this and how it works. Have you tried printing out “temp” immediately before your first if to see what the value is?
wk3000sgMembererr…how do u display variable temp from servlet to html???
Riyad KallaMemberYou don’t, just print it out and look at your Tomcat (or other) application server console you should see a line with the output in it.
wk3000sgMemberwhat is the statement to print?
Riyad KallaMemberSystem.out.println(“temp’s value is: [” + temp + “]”);
that way you can tell what the value of Temp is and maybe why the if-condition isn’t being hit.
wk3000sgMemberoh…sry…i knew it….thanks for your paitients. A hundred thanks here!!
-
AuthorPosts