Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP redirect problem.

 
Ikasari Widiyanto
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I got a problem in jsp I hope somebody can help me...
I have a form tag like this:

<form name="form1" method="post" action="request_action1.jsp?action=addmorerequest?requestNo=<%=requestNo%>">

then the request_action1.jsp is something like this:

if(action.equals("addmorerequest"))
{
System.out.println("I'm here");
String requestType = request.getParameter("requestType");
System.out.println("requestType:" + requestType);
String requestNo =request.getParameter("requestNo");
System.out.println("requestNo:"+requestNo);
String description = request.getParameter("description");
System.out.println("description:"+description);
String totalcost = request.getParameter("totalcost");
System.out.println("totalcost:"+totalcost);
String unitcost = request.getParameter("unit_cost");
System.out.println("unitcost:"+unitcost);
String quantity = request.getParameter("quantity");
System.out.println("quantity:"+quantity);
String supplier = request.getParameter("supplier");
System.out.println("supplier:"+supplier);
String verifyppl =request.getParameter("verifyppl");

try
{
sql = "UPDATE requestheader SET detail = 'Y' WHERE requestNo = "+requestNo;
stmt.executeUpdate(sql);
System.out.println("sql1");
sql = "insert into requestdetail (requestNo, supplier, createdBy, createdOn, quantity, unitcost, totalcost, description) values ('"+requestNo+"', '"+supplier+"', '"+userId+"',now(),"+quantity+", "+unitcost+", "+totalcost+", '"+description+"')";
stmt.executeUpdate(sql);
System.out.println("sql2");
sql = "insert into actionrecord (refid, category, actions, fromppl, toppl, remark, createdDate) values ('"+requestNo+"', 'Request', 'Require Verify', '"+userId+"', '"+verifyppl+"', '', now())";
stmt.executeUpdate(sql);
System.out.println("sql3");
stmt.close();
}catch (Exception e)
{
System.out.println("error:" + e.getMessage());
}
%>
<script>
var id = "<%=requestNo%>"
alert ('This request No '+id+' has been added')
</script>
<%
response.sendRedirect("addRequestDetails.jsp?form=addDetails&requestNo="+requestNo);
System.out.println("end of the script");
//}
//out.print(sql);
}
%>

when I try to run it then the page is blank... can any body help me to debug this?
 
Shailesh Chandra
Ranch Hand
Posts: 1082
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
there are number of system.out.println

which is last system.out.println you can see

is there any exception ???
 
Praful Thakare
Ranch Hand
Posts: 642
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


1) I guess the second ? must be replaced with &
2) As Shailesh said chek out which is the last System.out.pritln
executed sucessfuly
3) There is no out.println() in this code so nothing will be printed other
then an alert box,is it poping up ?
4) if this page works fine without exception then chek out
addRequestDetails.jsp as you are redirecting request to this page

Cheers
-Praful
 
Ikasari Widiyanto
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok... thanks..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic