[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How to properly compile java

Posted on 2011-03-24
4
Medium Priority
?
332 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 28

Accepted Solution

by:
rrz earned 1000 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 28

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Originally, this post was published on Monitis Blog, you can check it here . It goes without saying that technology has transformed society and the very nature of how we live, work, and communicate in ways that would’ve been incomprehensible 5 ye…
The first step to building an amazing About page is to figure out what you want the page to say about your company. You then must grab the attention of the reader, boast a bit, tell a story and let others brag about you. With a little bit of thought…
The viewer will learn how to count occurrences of each item in an array.
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).
Suggested Courses

830 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