Solved

How to properly compile java

Posted on 2011-03-24
4
327 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone 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

FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
This video teaches users how to migrate an existing Wordpress website to a new domain.
The viewer will learn how to count occurrences of each item in an array.

707 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