Solved

How to properly compile java

Posted on 2011-03-24
4
324 Views
Last Modified: 2012-05-11
I'm getting the error method getCardType() is undefined for type trackDataForm. I have enclosed 2 files in which I have defined the getter getCardType() and I have called it with the instance in the other file DoDirectPaymentReceipt2.jsp. it looks like it should be correct because I have not deviated from the way the other setters and getters were defined. The others work. That makes me think that this is a problem with the compiling. What has  happened is that I took the file trackDataForm.java which was working and then I added this setter and getter for cardType. Then even though I compile it with javac and replace to generated the .class file with the original .class. it gives this error. My guess is it has  something to do with the paths or the environment. I'm developing on Linux.
0
Comment
Question by:Jeff swicegood
  • 2
  • 2
4 Comments
 
LVL 1

Author Comment

by:Jeff swicegood
ID: 35210120
Oops I forgot to include the code files.
<meta http-equiv="Refresh" content="60;url=http://localhost:8080/start.jsp">

<%@ page import="com.paypal.sdk.services.NVPCallerServices" %>
<%@ page import="com.paypal.sdk.util.*" %>
<%@ page import="com.paypal.sdk.profiles.APIProfile" %>
<%@ page import="com.paypal.sdk.profiles.ProfileFactory" %>
<%@ page import="com.paypal.sdk.core.nvp.NVPEncoder" %>
<%@ page import="com.paypal.sdk.core.nvp.NVPDecoder" %>
<%@ page import="java.util.*" %>
<%@ page language="java" %>

<jsp:useBean id="trackData" class="org.iskcon.newgoloka.trackDataForm" scope="session"/>
<jsp:setProperty name="trackData" property="*"/>
<html>
<head>
    <title>PayPal JSP SDK - DoDirectPayment API</title>
    <link href="sdk.css" rel="stylesheet" type="text/css" />
</head>
<body>

<%

	NVPCallerServices caller = null;


   	try {
		caller = new NVPCallerServices();
		APIProfile profile = null;
		profile = ProfileFactory.createSignatureAPIProfile();
			/*
			 WARNING: Do not embed plaintext credentials in your application code.
			 Doing so is insecure and against best practices.
			 Your API credentials must be handled securely. Please consider
			 encrypting them for use in any production environment, and ensure
			 that only authorized individuals may view or modify them.
			 */
		// Set up your API credentials, PayPal end point, API operation and version.
		profile.setAPIUsername("jguru1_1299951140_biz_api1.gmail.com");
		profile.setAPIPassword("1299951153");
		profile.setSignature("A.yRbdgVR.FNMLJiQFfJi4tK-7rWAOa7xUMFr4kE6.XVbNJk26DjsEBW");
	        profile.setEnvironment("sandbox");
	        profile.setSubject("");
	        caller.setAPIProfile(profile);
// Format donationamount for encoding

String amount = trackData.getDonationAmount();
amount = amount.replace('$',' ').trim();
if(amount.indexOf(".") == -1){
amount = amount.concat(".00");
}
				
		int eq = trackData.getTrackData().indexOf("=");
		
//NVPEncoder object is created and all the name value pairs are loaded into it.	

		NVPEncoder encoder = new NVPEncoder();

		encoder.add("METHOD","DoDirectPayment");
		encoder.add("PAYMENTACTION","Sale");
		encoder.add("AMT",(String)amount);
		encoder.add("CREDITCARDTYPE",(String)trackData.getCardType());		
		encoder.add("ACCT",(String)trackData.getTrackData().substring(1,eq));					
		encoder.add("EXPDATE",trackData.getTrackData().substring(eq+3,eq+5)+"20"+trackData.getTrackData().substring(eq+1,eq+3));
		encoder.add("CVV2","678");
		encoder.add("FIRSTNAME",(String)trackData.getFirstName());
		encoder.add("LASTNAME",(String)trackData.getLastName());										
		encoder.add("STREET",(String)trackData.getAddress1());
		encoder.add("CITY",(String)trackData.getCity());	
		encoder.add("STATE",(String)trackData.getState());			
		encoder.add("ZIP",(String)trackData.getZipCode());	
		encoder.add("COUNTRYCODE","US");	
		//encoder.add("CURRENCYCODE",(String)request.getParameter("currency"));													
		encoder.add("CURRENCYCODE","USD");													
		//encode method will encode the name and value and form NVP string for the request		
		String NVPString = encoder.encode();
		
		//call method will send the request to the server and return the response NVPString		
		String ppresponse = (String) caller.call(NVPString);
		//NVPDecoder object is created		
		NVPDecoder resultValues = new NVPDecoder();
		//decode method of NVPDecoder will parse the request and decode the name and value pair			
		resultValues.decode(ppresponse);
		
		   ResponseBuilder rb=new ResponseBuilder();
		   String header1="Do Direct Payment";
		   String header2="Thank you for your payment!";
		   String resp=rb.BuildResponse(resultValues,header1,header2);
	
			//checks for Acknowledgement and redirects accordingly to display error messages					
			String strAck = resultValues.get("ACK"); 
			if(strAck !=null && !(strAck.equals("Success") || strAck.equals("SuccessWithWarning")))
			{
				session.setAttribute("response",resultValues);
				response.sendRedirect("APIError.jsp");
				return;
			}
			
%>

    <%=resp %>
    <a id="CallsLink" href="Calls.html">Home</a>
      <%
    
    } catch (Exception e) {
		session.setAttribute("exception", e);
		response.sendRedirect("Error.jsp");
		return;
	}
    
    %>
</body>
</html>

Open in new window

trackDataForm.java
0
 
LVL 27

Accepted Solution

by:
rrz earned 250 total points
ID: 35210404
Your code looks good. Did you stop and start your server ? Are you using Tomcat ?
0
 
LVL 1

Author Comment

by:Jeff swicegood
ID: 35215616
OMG, I can't believe it was that simple. When I stopped and restarted the server it worked! Yes I'm using Tomcat.
0
 
LVL 27

Expert Comment

by:rrz
ID: 35216796
When Tomcat deploy your web app it loads your classes.
If your environment allows it, then you could use Tomcat's Manager app to redeploy.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
"In order to have an organized way for empathy mapping, we rely on a psychological model and trying to model it in a simple way, so we will split the board to three section for each persona and a scenario and try to see what those personas would Do,…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question