Solved

How to properly compile java

Posted on 2011-03-24
4
325 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

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

"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,…
Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
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.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

821 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