Solved

How to properly compile java

Posted on 2011-03-24
4
323 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
Comment Utility
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
Comment Utility
Your code looks good. Did you stop and start your server ? Are you using Tomcat ?
0
 
LVL 1

Author Comment

by:Jeff swicegood
Comment Utility
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
Comment Utility
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Accessibility and Usability are two concepts that seem to be closely related.  But, too many people seem to have a distorted perception of them. During last five years, those two words have come to the day-to-day work of almost every web develope‚Ķ
Read about why website design really matters in today's demanding market.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

728 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now