467,907 Members | 1,432 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,907 developers. It's quick & easy.

I can't figure out the error. No error is being displayed in My EclipseIDE..

lifeisgreat20009
What might be the possible cause ?
I have created a website using struts framework, jsp
In my transaction page the money is not getting transferred..
When I hit the submit button in my Transaction.jsp page , no transaction happens ..
Only the url changes from

http://localhost:8080/bankfinalproje...ransaction.jsp

to this

http://localhost:8080/bankfinalproject/transaction.do

Below are my files

struts-config.xml

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd">
  3.  
  4. <struts-config>
  5.     <data-sources>
  6.         <data-source type="org.apache.commons.dbcp.BasicDataSource">
  7.             <set-property property="driverClassName"
  8.                 value="com.mysql.jdbc.Driver" />
  9.             <set-property property="url"
  10.                 value="jdbc:mysql://localhost:3306/bank_sys?autoReconnect=true" />
  11.             <set-property property="username" value="root" />
  12.             <set-property property="password" value="hr" />
  13.             <set-property property="maxActive" value="40" />
  14.             <set-property property="maxWait" value="5000" />
  15.             <set-property property="defaultAutoCommit" value="true" />
  16.             <set-property property="defaultReadOnly" value="false" />
  17.             <set-property property="maxActive" value="10" />
  18.             <set-property property="maxWait" value="5000" />
  19.             <set-property property="defaultReadOnly" value="false" />
  20.         </data-source>
  21.     </data-sources>
  22.  
  23.     <form-beans>
  24.         <form-bean name="searchCustomerForm"
  25.             type="com.kmg.bank.form.SearchCustomerForm" />
  26.         <form-bean name="editCustomerForm"
  27.             type="com.kmg.bank.form.EditCustomerForm" />
  28.         <form-bean name="searchEmpForm"
  29.             type="com.kmg.bank.form.SearchEmpForm" />
  30.         <form-bean name="editEmpForm"
  31.             type="com.kmg.bank.form.EditEmpForm" />
  32.         <form-bean name="index1Form"
  33.             type="com.kmg.bank.form.Index1Form" />
  34.         <form-bean name="index2Form"
  35.             type="com.kmg.bank.form.Index2Form" />
  36.         <form-bean name="newEmployeeForm"
  37.             type="com.kmg.bank.form.NewEmployeeForm" />
  38.         <form-bean name="newCustomerForm"
  39.             type="com.kmg.bank.form.NewCustomerForm" />
  40.         <form-bean name="transactionForm"
  41.             type="com.kmg.bank.form.TransactionForm" />
  42.  
  43.         <form-bean name="activateForm"
  44.             type="com.kmg.bank.form.ActivateForm" />
  45.  
  46.     </form-beans>
  47.     <global-forwards>
  48.         <forward name="/transac" path="/jsp/transaction.jsp"></forward>
  49.         <forward name="activate" path="/jsp/accntList.jsp"></forward>
  50.     </global-forwards>
  51.  
  52.     <action-mappings>
  53.         <action attribute="searchCustomerForm"
  54.             input="/jsp/searchCustomer.jsp" name="searchCustomerForm"
  55.             path="/searchCustomer" scope="request" validate="true"
  56.             type="com.kmg.bank.action.SearchCustomerAction">
  57.             <forward name="result" path="/jsp/customerSearchResult.jsp" />
  58.         </action>
  59.         <action attribute="editCustomerForm"
  60.             input="/jsp/editCustomer.jsp" parameter="do" name="editCustomerForm"
  61.             path="/editCustomer" scope="request" validate="true"
  62.             type="com.kmg.bank.action.EditCustomerAction">
  63.             <forward name="changed" path="/jsp/updatedCustomer.jsp" />
  64.             <forward name="edit" path="/jsp/editCustomer.jsp" />
  65.         </action>
  66.         <action attribute="searchEmpForm" input="/jsp/searchEmp.jsp"
  67.             name="searchEmpForm" path="/searchEmp" scope="request" validate="true"
  68.             type="com.kmg.bank.action.SearchEmpAction">
  69.             <forward name="resultEmp" path="/jsp/empSearchResult.jsp" />
  70.  
  71.         </action>
  72.         <action attribute="editEmpForm" input="/jsp/editEmp.jsp"
  73.             name="editEmpForm" parameter="do" path="/editEmp" scope="request" validate="true"
  74.             type="com.kmg.bank.action.EditEmpAction">
  75.             <forward name="updatedEmp" path="/jsp/updatedEmp.jsp" />
  76.             <forward name="editEmp" path="/jsp/editEmp.jsp" />
  77.         </action>
  78.         <action path="/index1" type="com.kmg.bank.action.Index1Action" validate="true"
  79.             name="index1Form" input="/jsp/index1.jsp">
  80.             <forward name="accountDetail" path="/jsp/accountDetail.jsp" />
  81.         </action>
  82.  
  83.         <action path="/index2" type="com.kmg.bank.action.Index2Action" validate="true"
  84.             parameter="do" name="index2Form" input="/jsp/index2.jsp">
  85.             <forward name="employeeDetail"
  86.                 path="/jsp/employeeDetail.jsp" />
  87.                 <forward name="logout"
  88.                 path="/jsp/logout.jsp" />
  89.         </action>
  90.  
  91.         <action attribute="newEmployeeForm" input="/jsp/newEmployee.jsp" validate="true"
  92.             name="newEmployeeForm" path="/newEmployee" scope="request"
  93.             type="com.kmg.bank.action.NewEmployeeAction">
  94.             <forward name="success1"
  95.                 path="/jsp/success1.jsp" />
  96.         </action>
  97.  
  98.         <action attribute="newCustomerForm" input="/jsp/newCustomer.jsp"
  99.             name="newCustomerForm" path="/newCustomer" scope="request" validate="true"
  100.             type="com.kmg.bank.action.NewCustomerAction">
  101.             <forward name="success" path="/jsp/success.jsp" />
  102.         </action>
  103.  
  104.         <action attribute="accntListForm" input="/jsp/accntList.jsp"
  105.             name="accntListForm" parameter="do" path="/accntList" scope="request" validate="true"
  106.             type="com.kmg.bank.action.AccntListAction">
  107.             <forward name="showList" path="/jsp/accntList.jsp" />
  108.         </action>
  109.         <action attribute="transactionForm" input="/jsp/transaction.jsp"
  110.             name="transactionForm" path="/transaction" scope="request" validate="true"
  111.             type="com.kmg.bank.action.TransactionAction" >
  112.             <forward name="accountDetail" path="/jsp/accountDetail.jsp" />
  113.         </action>
  114.         <action attribute="activateForm" input="/jsp/activate.jsp"
  115.             path="/activate" scope="request" name="activateForm" validate="true"
  116.             type="com.kmg.bank.action.ActivateAction">
  117.             <forward name="activated"
  118.                 path="/jsp/activated.jsp" />
  119.         </action>
  120.  
  121.     </action-mappings>
  122.  
  123.     <message-resources parameter="com.kmg.bank.ApplicationResources" />
  124.     <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
  125.         <set-property property="pathnames"
  126.             value="/WEB-INF/validator-rules.xml,
  127.                /WEB-INF/validation.xml" />
  128.     </plug-in>
  129. </struts-config>
  130.  
  131.  

transaction.jsp

Expand|Select|Wrap|Line Numbers
  1. <%@ page language="java" pageEncoding="ISO-8859-1"%>
  2. <%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
  3. <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
  4.  
  5. <html>
  6.     <head>
  7.         <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  8.         <title>corporate bank</title>
  9.         <meta name="keywords" content="" />
  10.         <meta name="description" content="" />
  11.         <link href="styles.css" rel="stylesheet" type="text/css"
  12.             media="screen" />
  13.     </head>
  14.     <body>
  15.         <div id="main">
  16.             <!-- start header -->
  17.             <div id="header">
  18.                 <div id="logo">
  19.                     <h1>
  20.                         Corporate Bank
  21.                     </h1>
  22.                 </div>
  23.                 <!--Header end -->
  24.                 <div id="menu">
  25.                     <ul>
  26.                         <li>
  27.                             <a href="#">Home</a>
  28.                         </li>
  29.                         <li>
  30.                             <a href="products.jsp">Products</a>
  31.                         </li>
  32.                         <li>
  33.                             <a href="loans.jsp">Easy loans</a>
  34.                         </li>
  35.                         <li>
  36.                             <a href="aboutus.jsp">About us</a>
  37.                         </li>
  38.                         <li>
  39.                             <a href="contact.jsp">Contact</a>
  40.                         </li>
  41.                     </ul>
  42.                 </div>
  43.             </div>
  44.  
  45.             <!-- end header -->
  46.             <!-- start page -->
  47.             <div id="page">
  48.                 <!-- start leftbar -->
  49.                 <div id="leftbar" class="sidebar">
  50.                     <h2>
  51.                         Branch Network
  52.                     </h2>
  53.  
  54.                     <div class="back">
  55.  
  56.                         <ul>
  57.                             <li>
  58.                                 <a href="branches.jsp">Branches</a>
  59.                             </li>
  60.                             <li>
  61.                                 <a href="atm.jsp">ATMs</a>
  62.                             </li>
  63.                             <li>
  64.                                 <a href="foreignBranches.jsp">Overseas Branches</a>
  65.                             </li>
  66.                             <li>
  67.                                 <a href="phoneNumbers.jsp">Phone banking numbers</a>
  68.                             </li>
  69.  
  70.                         </ul>
  71.                     </div>
  72.                     <div class="bottom"></div>
  73.                     <h2>
  74.                         Information
  75.                     </h2>
  76.                     <div class="back">
  77.                         <ul>
  78.                             <li>
  79.                                 <a href="interestRates.jsp">Interest rates on FD</a>
  80.                             </li>
  81.                             <li>
  82.                                 <a href="associateBanks.jsp">Associate Banks</a>
  83.                             </li>
  84.  
  85.  
  86.                             <li>
  87.                                 <a href="faq.jsp">FAQ's</a>
  88.                             </li>
  89.                         </ul>
  90.                         <br>
  91.                         <br>
  92.                     </div>
  93.                     <div class="bottom"></div>
  94.                 </div>
  95.  
  96.                 <!-- end leftbar -->
  97.                 <!-- start content -->
  98.                 <div id="content">
  99.                     <div class="post">
  100.                         <h1 class="title">
  101.                             Transaction
  102.                         </h1>
  103.                         <br>
  104.                         <br>
  105.  
  106.                         <html:form action="/transaction">
  107.                             <center>
  108.                                 <table>
  109.                                     <tr>
  110.                                         <td>
  111.                                             Accnt No:
  112.                                         </td>
  113.                                         <td>
  114.                                             ${accntNo}
  115.                                         </td>
  116.                                     </tr>
  117.                                     <tr></tr>
  118.                                     <tr></tr>
  119.                                     <tr></tr>
  120.                                     <tr></tr>
  121.                                     <tr></tr>
  122.                                     <tr>
  123.                                         <td>
  124.                                             Amount to be transfered:
  125.                                         </td>
  126.                                         <td>
  127.                                             <html:text property="amnt" />
  128.                                         </td>
  129.                                     </tr>
  130.                                     <tr>
  131.                                         <td colspan=2>
  132.                                             <center>
  133.                                                 <html:messages id="err_amnt" property="amnt">
  134.                                                     <font color="red"><bean:write name="err_amnt" /> </font>
  135.                                                 </html:messages>
  136.                                             </center>
  137.                                         </td>
  138.                                     </tr>
  139.                                     <tr></tr>
  140.                                     <tr></tr>
  141.                                     <tr></tr>
  142.                                     <tr></tr>
  143.                                     <tr>
  144.                                         <td>
  145.                                             Pay to Account No:
  146.                                         </td>
  147.                                         <td>
  148.                                             <html:text property="payTo" />
  149.                                     </tr>
  150.                                     <tr>
  151.                                         <td colspan=2>
  152.                                             <center>
  153.                                                 <html:messages id="err_payTo" property="payTo">
  154.                                                     <font color="red"><bean:write name="err_payTo" />
  155.                                                     </font>
  156.                                                 </html:messages>
  157.                                             </center>
  158.                                         </td>
  159.                                     </tr>
  160.                                     <tr></tr>
  161.                                     <tr></tr>
  162.                                     <tr></tr>
  163.                                     <tr></tr>
  164.                                     <tr></tr>
  165.                                     <tr></tr>
  166.                                     <tr>
  167.                                         <td>
  168.                                             Re-enter Account No:
  169.                                         </td>
  170.                                         <td>
  171.                                             <html:text property="rePayTo" />
  172.                                         </td>
  173.                                     </tr>
  174.                                     <tr></tr>
  175.                                     <tr>
  176.                                         <td colspan=2>
  177.                                             <center>
  178.                                                 <html:messages id="err_rePayTo" property="rePayTo">
  179.                                                     <font color="red"><bean:write name="err_rePayTo" />
  180.                                                     </font>
  181.                                                 </html:messages>
  182.                                             </center>
  183.                                         </td>
  184.                                     </tr>
  185.                                     <tr></tr>
  186.                                     <tr></tr>
  187.                                     <tr></tr>
  188.                                     <tr></tr>
  189.                                     <tr></tr>
  190.                                     <tr>
  191.                                         <td>
  192.                                             <center>
  193.                                                 <html:submit value="Transfer" />
  194.                                             </center>
  195.                                         </td>
  196.                                         <td>
  197.                                             <center>
  198.                                                 <html:reset />
  199.                                             </center>
  200.                                         </td>
  201.  
  202.                                     </tr>
  203.                                 </table>
  204.                             </center>
  205.                         </html:form>
  206.                         <br>
  207.                         <br>
  208.                         <br>
  209.                         <br>
  210.                         <br>
  211.                     </div>
  212.                 </div>
  213.                 <!-- end content -->
  214.                 <!-- start rightbar -->
  215.                 <div id="rightbar" class="sidebar">
  216.                     <h2>
  217.                         Login
  218.                     </h2>
  219.                     <div class="back">
  220.                         <form action="">
  221.                             <center>
  222.                                 <table>
  223.                                     <tr>
  224.                                         <td color=#000000>
  225.                                             You have logged in as:
  226.                                         </td>
  227.                                     </tr>
  228.                                     <tr>
  229.                                         <td>
  230.                                             <center>
  231.                                                 .......
  232.                                             </center>
  233.                                         </td>
  234.                                     </tr>
  235.                                     <tr></tr>
  236.                                     <tr></tr>
  237.                                     <tr></tr>
  238.                                     <tr></tr>
  239.                                     <tr></tr>
  240.                                     <tr></tr>
  241.                                     <tr></tr>
  242.                                     <tr></tr>
  243.                                     <tr></tr>
  244.                                     <tr></tr>
  245.                                     <tr></tr>
  246.                                     <tr></tr>
  247.                                     <tr></tr>
  248.                                     <tr>
  249.                                         <td>
  250.                                             <center>
  251.                                                 <a href="#">logout<a><center>
  252.                                         </td>
  253.                                     </tr>
  254.                                     <tr></tr>
  255.                                     <tr></tr>
  256.                                 </table>
  257.                             </center>
  258.                         </form>
  259.  
  260.                     </div>
  261.                     <div class="bottom"></div>
  262.                     <h2>
  263.                         News
  264.                     </h2>
  265.                     <div class="back">
  266.                         <ul>
  267.                             <li>
  268.                                 <a href="award.jsp">CNN-IBN Indian of the Year Award</a>
  269.                             </li>
  270.  
  271.                             <li>
  272.                                 <a href="tieup.jsp">Corporate Bank Ties up with Indian
  273.                                     Institute of Human Rights</a>
  274.                             </li>
  275.  
  276.                         </ul>
  277.                     </div>
  278.                     <div class="bottom"></div>
  279.                 </div>
  280.                 <!-- end rightbar -->
  281.                 <div style="clear: both;">
  282.                     &nbsp;
  283.                 </div>
  284.             </div>
  285.             <!-- end page -->
  286.             <div id="footer">
  287.                 <p>
  288.                     Copyright &copy; 2009.
  289.                     <a href="privacyPolicy.jsp">Privacy Policy</a> |
  290.                     <a href="faq.jsp">FAQs</a>
  291.                 </p>
  292.                 <p>
  293.                     Created by Anuj, Gaytri, Simrat
  294.  
  295.                 </p>
  296.  
  297.             </div>
  298.         </div>
  299.     </body>
  300. </html>
  301.  
  302.  

TransactionAction.java

Expand|Select|Wrap|Line Numbers
  1. package com.kmg.bank.action;
  2.  
  3. import java.io.PrintWriter;
  4. import java.sql.Connection;
  5. import java.util.ArrayList;
  6. import java.util.Iterator;
  7.  
  8. import javax.servlet.http.HttpServletRequest;
  9. import javax.servlet.http.HttpServletResponse;
  10. import javax.servlet.http.HttpSession;
  11. import javax.sql.DataSource;
  12.  
  13. import org.apache.struts.action.Action;
  14. import org.apache.struts.action.ActionForm;
  15. import org.apache.struts.action.ActionForward;
  16. import org.apache.struts.action.ActionMapping;
  17.  
  18. import com.kmg.bank.form.*;
  19. import com.kmg.bank.service.AccountDAO;
  20. import com.kmg.bank.service.TransactionDAO;
  21. import com.kmg.bank.*;
  22.  
  23. public class TransactionAction extends Action {
  24.     public ActionForward execute(ActionMapping mapping, ActionForm form,
  25.             HttpServletRequest request, HttpServletResponse response)
  26.             throws Exception {
  27.  
  28.         TransactionForm transactionForm = (TransactionForm) form;
  29.         TransactionDAO service = new TransactionDAO();
  30.         Connection con = null;
  31.         Transaction transaction=new Transaction();
  32.         HttpSession session= request.getSession();
  33.         AccountDAO accountDAO=new AccountDAO();
  34.         ArrayList list=null;
  35.         Iterator iterator=null;
  36.  
  37.         Integer accntNo=(Integer)session.getAttribute("accntNo");
  38.         transaction.setAccntNo(accntNo.intValue());
  39.         transaction.setAmnt(transactionForm.getAmnt());
  40.         transaction.setPayTo(transactionForm.getPayTo());
  41.         System.out.println(transaction.getAmnt());
  42.         DataSource ds = getDataSource(request);
  43.         con=service.getConnection(ds);
  44.         int a=service.editAccnt(con, transaction);
  45.         int b=service.editPayToAccnt(con, transaction);
  46.         int c=service.addRecord(con, transaction);
  47.         list=accountDAO.searchByAccntNo(con, transaction.getAccntNo());
  48.         float bal=0;
  49.         iterator=list.iterator();
  50.         while(iterator.hasNext())
  51.         {
  52.             Account account=(Account)iterator.next();
  53.             bal=account.getBalance();
  54.  
  55.         }
  56.         session.setAttribute("balance", Float.valueOf(bal));
  57.  
  58.         if(a>0 && b>0 && c>0)
  59.             System.out.println("transaction successful");
  60.         //service.closeConnection(con);
  61.         return mapping.findForward("accountDetail");
  62.     }
  63. }
  64.  

Why is nothing happening ????????
May 25 '09 #1
  • viewed: 2316
Share:
8 Replies
8TB
That's a terribly huge amount of code.
Better first check to see if your action is getting called at all.
Put some output statements in your action and check to see if the action is called at all.
May 26 '09 #2
100+
Better you compress the project into zip and upload here..
@lifeisgreat20009
May 26 '09 #3
100+
Check action attribute of the form...

"action='/transaction'"

it is wrong,

you should use "action='transaction'"
May 26 '09 #4
lifeisgreat20009
I changed that attribute into "action='transaction'"
but its still not working.

I did put output statement in the TransactionAction.java file

Nothing is being displayed on the console which means this action class is not being called..
why so ?
May 26 '09 #5
lifeisgreat20009
I just did some research and found this

http://www.junlu.com/msg/196517.html

Is my problem related to this ??

My validations on transaction page are working fine..
So what else could be the problem ??
Action class is just not being called, no updation in database are happening
May 26 '09 #6
Expert 8TB
Your (beginner's) mistake is that you started typing like hell and when you finally finished you attempted to run it; it didn't work of course and then you threw your hands up in the air in pure despair and posted all that wallpaper in this group.

What you should've done is take baby steps, i.e. write a bit of code, compile it, run it and test if it runs how you want it to run. Then write a bit more and repeat the cycle. If at some iteration stuff doesn't work anymore you can perfectly precise show us what is wrong and what you expect it to do.

It's too late now because you're still sitting there with your hands up in the air in despair, waiting for the magic bullet to be posted here. That is not the way software development goes. You (at least) have to actively try to find the bug, not reply "I did what you suggested but it didn't work; help! It's urgent!".

Use Descartes' "reductionism", i.e. reduce your problem until you've found the part that is not working and leave out the rest. Nobody is interested in your wallpaper and nobody wants to go through it all; it is your work. Some output is not produced; why not? Something isn't called; try to figure out why not; maybe you have to write some throw-away test code that simulates what you actually want to accomplish. But most important of it all: think.

kind regards,

Jos
May 26 '09 #7
lifeisgreat20009
woah..
LMAO !!!

I guess I needed that...

Thanks :)
May 26 '09 #8
dlite922
Expert 1GB
@lifeisgreat20009
By the way, Jos is one of the nicest on byte, and I agree, that's the nicest he could have put it.

Did you "learn" something from this thread though? Did you learn about the acyclic life cycle of coding and the all important troubleshooting skills.

Print statements are your best friend. Every programmer should know how the code is executed, put a print() statement at every step like breadcrumbs, it will always lead you to your problem.

Don't Give Up,






Dan
May 28 '09 #9

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

6 posts views Thread by Matt | last post: by
8 posts views Thread by middletree | last post: by
3 posts views Thread by Professor Frink | last post: by
reply views Thread by Mark Phanides | last post: by
12 posts views Thread by mark2kay | last post: by
8 posts views Thread by =?Utf-8?B?R3JlZyBMYXJzZW4=?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.