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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lifeisgreat20009
    New Member
    • Oct 2007
    • 70

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

    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



    to this



    Below are my files

    struts-config.xml

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd">
    
    <struts-config>
    	<data-sources>
    		<data-source type="org.apache.commons.dbcp.BasicDataSource">
    			<set-property property="driverClassName"
    				value="com.mysql.jdbc.Driver" />
    			<set-property property="url"
    				value="jdbc:mysql://localhost:3306/bank_sys?autoReconnect=true" />
    			<set-property property="username" value="root" />
    			<set-property property="password" value="hr" />
    			<set-property property="maxActive" value="40" />
    			<set-property property="maxWait" value="5000" />
    			<set-property property="defaultAutoCommit" value="true" />
    			<set-property property="defaultReadOnly" value="false" />
    			<set-property property="maxActive" value="10" />
    			<set-property property="maxWait" value="5000" />
    			<set-property property="defaultReadOnly" value="false" />
    		</data-source>
    	</data-sources>
    
    	<form-beans>
    		<form-bean name="searchCustomerForm"
    			type="com.kmg.bank.form.SearchCustomerForm" />
    		<form-bean name="editCustomerForm"
    			type="com.kmg.bank.form.EditCustomerForm" />
    		<form-bean name="searchEmpForm"
    			type="com.kmg.bank.form.SearchEmpForm" />
    		<form-bean name="editEmpForm"
    			type="com.kmg.bank.form.EditEmpForm" />
    		<form-bean name="index1Form"
    			type="com.kmg.bank.form.Index1Form" />
    		<form-bean name="index2Form"
    			type="com.kmg.bank.form.Index2Form" />
    		<form-bean name="newEmployeeForm"
    			type="com.kmg.bank.form.NewEmployeeForm" />
    		<form-bean name="newCustomerForm"
    			type="com.kmg.bank.form.NewCustomerForm" />
    		<form-bean name="transactionForm"
    			type="com.kmg.bank.form.TransactionForm" />
    		
    		<form-bean name="activateForm"
    			type="com.kmg.bank.form.ActivateForm" />
    
    	</form-beans>
    	<global-forwards>
    		<forward name="/transac" path="/jsp/transaction.jsp"></forward>
    		<forward name="activate" path="/jsp/accntList.jsp"></forward>
    	</global-forwards>
    
    	<action-mappings>
    		<action attribute="searchCustomerForm"
    			input="/jsp/searchCustomer.jsp" name="searchCustomerForm"
    			path="/searchCustomer" scope="request" validate="true"
    			type="com.kmg.bank.action.SearchCustomerAction">
    			<forward name="result" path="/jsp/customerSearchResult.jsp" />
    		</action>
    		<action attribute="editCustomerForm"
    			input="/jsp/editCustomer.jsp" parameter="do" name="editCustomerForm"
    			path="/editCustomer" scope="request" validate="true"
    			type="com.kmg.bank.action.EditCustomerAction">
    			<forward name="changed" path="/jsp/updatedCustomer.jsp" />
    			<forward name="edit" path="/jsp/editCustomer.jsp" />
    		</action>
    		<action attribute="searchEmpForm" input="/jsp/searchEmp.jsp"
    			name="searchEmpForm" path="/searchEmp" scope="request" validate="true"
    			type="com.kmg.bank.action.SearchEmpAction">
    			<forward name="resultEmp" path="/jsp/empSearchResult.jsp" />
    
    		</action>
    		<action attribute="editEmpForm" input="/jsp/editEmp.jsp"
    			name="editEmpForm" parameter="do" path="/editEmp" scope="request" validate="true"
    			type="com.kmg.bank.action.EditEmpAction">
    			<forward name="updatedEmp" path="/jsp/updatedEmp.jsp" />
    			<forward name="editEmp" path="/jsp/editEmp.jsp" />
    		</action>
    		<action path="/index1" type="com.kmg.bank.action.Index1Action" validate="true"
    			name="index1Form" input="/jsp/index1.jsp">
    			<forward name="accountDetail" path="/jsp/accountDetail.jsp" />
    		</action>
     
    		<action path="/index2" type="com.kmg.bank.action.Index2Action" validate="true"
    			parameter="do" name="index2Form" input="/jsp/index2.jsp">
    			<forward name="employeeDetail"
    				path="/jsp/employeeDetail.jsp" />
    				<forward name="logout"
    				path="/jsp/logout.jsp" />
    		</action>
    
    		<action attribute="newEmployeeForm" input="/jsp/newEmployee.jsp" validate="true"
    			name="newEmployeeForm" path="/newEmployee" scope="request"
    			type="com.kmg.bank.action.NewEmployeeAction">
    			<forward name="success1"
    				path="/jsp/success1.jsp" />
    		</action>
    
    		<action attribute="newCustomerForm" input="/jsp/newCustomer.jsp"
    			name="newCustomerForm" path="/newCustomer" scope="request" validate="true"
    			type="com.kmg.bank.action.NewCustomerAction">
    			<forward name="success" path="/jsp/success.jsp" />
    		</action>
    
    		<action attribute="accntListForm" input="/jsp/accntList.jsp"
    			name="accntListForm" parameter="do" path="/accntList" scope="request" validate="true"
    			type="com.kmg.bank.action.AccntListAction">
    			<forward name="showList" path="/jsp/accntList.jsp" />
    		</action>
    		<action attribute="transactionForm" input="/jsp/transaction.jsp"
    			name="transactionForm" path="/transaction" scope="request" validate="true"
    			type="com.kmg.bank.action.TransactionAction" >
    			<forward name="accountDetail" path="/jsp/accountDetail.jsp" />
    		</action>
    		<action attribute="activateForm" input="/jsp/activate.jsp"
    			path="/activate" scope="request" name="activateForm" validate="true"
    			type="com.kmg.bank.action.ActivateAction">
    			<forward name="activated"
    				path="/jsp/activated.jsp" />
    		</action>
    
    	</action-mappings>
    
    	<message-resources parameter="com.kmg.bank.ApplicationResources" />
    	<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
    		<set-property property="pathnames"
    			value="/WEB-INF/validator-rules.xml,
                   /WEB-INF/validation.xml" />
    	</plug-in>
    </struts-config>

    transaction.jsp

    Code:
    <%@ page language="java" pageEncoding="ISO-8859-1"%>
    <%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
    <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
    
    <html>
    	<head>
    		<meta http-equiv="content-type" content="text/html; charset=utf-8" />
    		<title>corporate bank</title>
    		<meta name="keywords" content="" />
    		<meta name="description" content="" />
    		<link href="styles.css" rel="stylesheet" type="text/css"
    			media="screen" />
    	</head>
    	<body>
    		<div id="main">
    			<!-- start header -->
    			<div id="header">
    				<div id="logo">
    					<h1>
    						Corporate Bank
    					</h1>
    				</div>
    				<!--Header end -->
    				<div id="menu">
    					<ul>
    						<li>
    							<a href="#">Home</a>
    						</li>
    						<li>
    							<a href="products.jsp">Products</a>
    						</li>
    						<li>
    							<a href="loans.jsp">Easy loans</a>
    						</li>
    						<li>
    							<a href="aboutus.jsp">About us</a>
    						</li>
    						<li>
    							<a href="contact.jsp">Contact</a>
    						</li>
    					</ul>
    				</div>
    			</div>
    
    			<!-- end header -->
    			<!-- start page -->
    			<div id="page">
    				<!-- start leftbar -->
    				<div id="leftbar" class="sidebar">
    					<h2>
    						Branch Network
    					</h2>
    
    					<div class="back">
    
    						<ul>
    							<li>
    								<a href="branches.jsp">Branches</a>
    							</li>
    							<li>
    								<a href="atm.jsp">ATMs</a>
    							</li>
    							<li>
    								<a href="foreignBranches.jsp">Overseas Branches</a>
    							</li>
    							<li>
    								<a href="phoneNumbers.jsp">Phone banking numbers</a>
    							</li>
    
    						</ul>
    					</div>
    					<div class="bottom"></div>
    					<h2>
    						Information
    					</h2>
    					<div class="back">
    						<ul>
    							<li>
    								<a href="interestRates.jsp">Interest rates on FD</a>
    							</li>
    							<li>
    								<a href="associateBanks.jsp">Associate Banks</a>
    							</li>
    
    
    							<li>
    								<a href="faq.jsp">FAQ's</a>
    							</li>
    						</ul>
    						<br>
    						<br>
    					</div>
    					<div class="bottom"></div>
    				</div>
    
    				<!-- end leftbar -->
    				<!-- start content -->
    				<div id="content">
    					<div class="post">
    						<h1 class="title">
    							Transaction
    						</h1>
    						<br>
    						<br>
    
    						<html:form action="/transaction">
    							<center>
    								<table>
    									<tr>
    										<td>
    											Accnt No:
    										</td>
    										<td>
    											${accntNo}
    										</td>
    									</tr>
    									<tr></tr>
    									<tr></tr>
    									<tr></tr>
    									<tr></tr>
    									<tr></tr>
    									<tr>
    										<td>
    											Amount to be transfered:
    										</td>
    										<td>
    											<html:text property="amnt" />
    										</td>
    									</tr>
    									<tr>
    										<td colspan=2>
    											<center>
    												<html:messages id="err_amnt" property="amnt">
    													<font color="red"><bean:write name="err_amnt" /> </font>
    												</html:messages>
    											</center>
    										</td>
    									</tr>
    									<tr></tr>
    									<tr></tr>
    									<tr></tr>
    									<tr></tr>
    									<tr>
    										<td>
    											Pay to Account No:
    										</td>
    										<td>
    											<html:text property="payTo" />
    									</tr>
    									<tr>
    										<td colspan=2>
    											<center>
    												<html:messages id="err_payTo" property="payTo">
    													<font color="red"><bean:write name="err_payTo" />
    													</font>
    												</html:messages>
    											</center>
    										</td>
    									</tr>
    									<tr></tr>
    									<tr></tr>
    									<tr></tr>
    									<tr></tr>
    									<tr></tr>
    									<tr></tr>
    									<tr>
    										<td>
    											Re-enter Account No:
    										</td>
    										<td>
    											<html:text property="rePayTo" />
    										</td>
    									</tr>
    									<tr></tr>
    									<tr>
    										<td colspan=2>
    											<center>
    												<html:messages id="err_rePayTo" property="rePayTo">
    													<font color="red"><bean:write name="err_rePayTo" />
    													</font>
    												</html:messages>
    											</center>
    										</td>
    									</tr>
    									<tr></tr>
    									<tr></tr>
    									<tr></tr>
    									<tr></tr>
    									<tr></tr>
    									<tr>
    										<td>
    											<center>
    												<html:submit value="Transfer" />
    											</center>
    										</td>
    										<td>
    											<center>
    												<html:reset />
    											</center>
    										</td>
    
    									</tr>
    								</table>
    							</center>
    						</html:form>
    						<br>
    						<br>
    						<br>
    						<br>
    						<br>
    					</div>
    				</div>
    				<!-- end content -->
    				<!-- start rightbar -->
    				<div id="rightbar" class="sidebar">
    					<h2>
    						Login
    					</h2>
    					<div class="back">
    						<form action="">
    							<center>
    								<table>
    									<tr>
    										<td color=#000000>
    											You have logged in as:
    										</td>
    									</tr>
    									<tr>
    										<td>
    											<center>
    												.......
    											</center>
    										</td>
    									</tr>
    									<tr></tr>
    									<tr></tr>
    									<tr></tr>
    									<tr></tr>
    									<tr></tr>
    									<tr></tr>
    									<tr></tr>
    									<tr></tr>
    									<tr></tr>
    									<tr></tr>
    									<tr></tr>
    									<tr></tr>
    									<tr></tr>
    									<tr>
    										<td>
    											<center>
    												<a href="#">logout<a><center>
    										</td>
    									</tr>
    									<tr></tr>
    									<tr></tr>
    								</table>
    							</center>
    						</form>
    
    					</div>
    					<div class="bottom"></div>
    					<h2>
    						News
    					</h2>
    					<div class="back">
    						<ul>
    							<li>
    								<a href="award.jsp">CNN-IBN Indian of the Year Award</a>
    							</li>
    
    							<li>
    								<a href="tieup.jsp">Corporate Bank Ties up with Indian
    									Institute of Human Rights</a>
    							</li>
    
    						</ul>
    					</div>
    					<div class="bottom"></div>
    				</div>
    				<!-- end rightbar -->
    				<div style="clear: both;">
    					&nbsp;
    				</div>
    			</div>
    			<!-- end page -->
    			<div id="footer">
    				<p>
    					Copyright &copy; 2009.
    					<a href="privacyPolicy.jsp">Privacy Policy</a> |
    					<a href="faq.jsp">FAQs</a>
    				</p>
    				<p>
    					Created by Anuj, Gaytri, Simrat
    
    				</p>
    
    			</div>
    		</div>
    	</body>
    </html>

    TransactionActi on.java

    Code:
    package com.kmg.bank.action;
    
    import java.io.PrintWriter;
    import java.sql.Connection;
    import java.util.ArrayList;
    import java.util.Iterator;
    
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.http.HttpSession;
    import javax.sql.DataSource;
    
    import org.apache.struts.action.Action;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionForward;
    import org.apache.struts.action.ActionMapping;
    
    import com.kmg.bank.form.*;
    import com.kmg.bank.service.AccountDAO;
    import com.kmg.bank.service.TransactionDAO;
    import com.kmg.bank.*;
    
    public class TransactionAction extends Action {
    	public ActionForward execute(ActionMapping mapping, ActionForm form,
    			HttpServletRequest request, HttpServletResponse response)
    			throws Exception {
    	
    		TransactionForm transactionForm = (TransactionForm) form;
    		TransactionDAO service = new TransactionDAO();
    		Connection con = null;
    		Transaction transaction=new Transaction();
    		HttpSession session= request.getSession();
    		AccountDAO accountDAO=new AccountDAO();
    		ArrayList list=null;
    		Iterator iterator=null;
    		
    		Integer accntNo=(Integer)session.getAttribute("accntNo");
    		transaction.setAccntNo(accntNo.intValue());
    		transaction.setAmnt(transactionForm.getAmnt());
    		transaction.setPayTo(transactionForm.getPayTo());
    		System.out.println(transaction.getAmnt());
    		DataSource ds = getDataSource(request);
    		con=service.getConnection(ds);
    		int a=service.editAccnt(con, transaction);
    		int b=service.editPayToAccnt(con, transaction);
    		int c=service.addRecord(con, transaction);
    		list=accountDAO.searchByAccntNo(con, transaction.getAccntNo());
    		float bal=0;
    		iterator=list.iterator();
    		while(iterator.hasNext())
    		{
    			Account account=(Account)iterator.next();
    			bal=account.getBalance();
    			
    		}
    		session.setAttribute("balance", Float.valueOf(bal));
    		
    		if(a>0 && b>0 && c>0)
    			System.out.println("transaction successful");
    		//service.closeConnection(con);
    		return mapping.findForward("accountDetail");
    	}
    }

    Why is nothing happening ????????
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    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.

    Comment

    • NitinSawant
      Contributor
      • Oct 2007
      • 271

      #3
      Better you compress the project into zip and upload here..
      @lifeisgreat200 09

      Comment

      • NitinSawant
        Contributor
        • Oct 2007
        • 271

        #4
        Check action attribute of the form...

        "action='/transaction'"

        it is wrong,

        you should use "action='transa ction'"

        Comment

        • lifeisgreat20009
          New Member
          • Oct 2007
          • 70

          #5
          I changed that attribute into "action='transa ction'"
          but its still not working.

          I did put output statement in the TransactionActi on.java file

          Nothing is being displayed on the console which means this action class is not being called..
          why so ?

          Comment

          • lifeisgreat20009
            New Member
            • Oct 2007
            • 70

            #6
            I just did some research and found this



            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

            Comment

            • JosAH
              Recognized Expert MVP
              • Mar 2007
              • 11453

              #7
              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' "reductioni sm", 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

              Comment

              • lifeisgreat20009
                New Member
                • Oct 2007
                • 70

                #8
                woah..
                LMAO !!!

                I guess I needed that...

                Thanks :)

                Comment

                • dlite922
                  Recognized Expert Top Contributor
                  • Dec 2007
                  • 1586

                  #9
                  Originally posted by lifeisgreat2000 9
                  woah..
                  LMAO !!!

                  I guess I needed that...

                  Thanks :)
                  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

                  Comment

                  Working...