Servlets :: Payment Gateway In Java
Jan 20, 2011How to implement the payment gateway in java.
View RepliesHow to implement the payment gateway in java.
View Repliescalculate how long it would take to pay off a loan of 500 pounds if there was 10% interest monthly, and 100 pounds was paid each month. This code is in a pseudocode,
set months = 1
set balance = 500
set totalpaid = 0;
while balance > 100
balance = balance - 100;
set interest = balance * 0.1
balance = balance + interest
totalpaid = totalpaid + 100
months = months + 1
endwhile
totalpaid = totalpaid+balance
display "you paid "+totalpaid
display "It took you "+months+" months"
I have a web application where the server has to write the excel document to the output stream.It takes more than 5 minutes for the server to write it.After 5 minutes i get a '504 gateway timeout' error code. I have tried setting the timeout values in the web container in Admin Console.Still the same problem.I followed this link.
[URL] ....
I even tried setting the ConnectionKeepAliveTimeout and ConnectionIOTimeOut values. But still didn't work. How do i increase the timeout value?
This is for a mortgage calculator and we have to use the math.pow method. I am getting results, but the results are wrong. The monthly payment is coming out to big.
Here is what it should be:
Enter loan amount: 10000
Enter rate: 4.5
Enter number years: 3
The monthly payment is: $297.47
Here is what I'm getting.
Enter loan amount: 10000
Enter rate: 4.5
Enter number years: 3
The monthly payment is: $566.06
Here is my code. I believe my issue is in the math.pow formula.
Scanner in = new Scanner(System.in); // input object
double loanAmount; //user input
double interestRate; // user input
double yearNumber; // user input
double monthlyPayment; // answer to math
double finalPayment; // output
double monthNumber; // year number converted of months
double monthlyRate; // converted intersted rate
[Code] ....
The monthly payment is: $%.2f", monthlyPayment); // Shows monthly payment
I want to Write a program that calculates the minimum fixed monthly payment needed in order pay off a credit card balance.
the Amount is 3,500 the annual rate is 9.9%, the minimum payment is 2% a month. the fixed payment is 150.
By a fixed monthly payment, we mean a single number which does not change each month, but instead is a constant amount that will be paid each month.
The program should print out :
payment information:
new balance total .......
current payment due .......
if you make minimum payment (2%) you will pay of in .... months and you Will end up paying an estimated total of $........
if you make the fixed rate payment, you will pay of in .... months and you Will end up paying an estimated total of $........ and you will save $........
I have a servlet. Users from other machines access that servlet and I want to capture the remote user's UserName and do validation over that.It's just a simple servlet and no login/password is present. I tried request.getRemoteUser(), but its of no luck.
View Replies View RelatedI get an json from http request. I want to create a corresponding Java object.
is there any automated mapping? Something called pojo or something else?
i want to generate n number of pdf here n will be some limit according to requirement so ultimately I have to generate more than 1 pdf same time with once running the code I Have some values associated with id i want to print those values with respective id's in pdf format, values can be in database or in some variable , which way i should go... i have some ideas either i can save those values in database and can make a single xml file from database of all records and then divide each node with different different pdf or directly get the values from database and generate the pdf.
View Replies View RelatedOn Form Submit my url changes from
1.localhost:8080/Workflow/admin/GetReports?fname=Form1
to
2.localhost:8080/Workflow/admin/EditReport
Form action is EditReport(Servlet Name).
Now on EditReport i perform the databse operations and forward the request to the GetReports?fname=Formname Servlet using Request Dispatcher.So that i am on the same page which is the first one (1) i started from.
Now Everything works fine on the .jsp page But the url remains unchanged that is the second one (2).
Now if i hit the URL again i.e. localhost:8080/Workflow/admin/EditReport it will give an error.
So how to rewrite the url i.e. from admin/EditReport to /admin/GetReports?fname=Formname after performing all the operations.?
I want to create a new instance of a Java model class for each new request coming to a servlet.
How to do that without doing that in doGet() or doPost().
I am on developing a web application (using struts). So most of my web application use cases are reading and presenting data to the users.
But i need to write the another set of programs to keep on reading the data from another data bases and update my database. I have list of timings at which i should read the data from each of other sites (i.e. i know when the other databases gets updated information). Its almost every 20 mins..
Now i want to design the app.
1. Should i include the data read programs as part of my Web application ( means runs in same server JVM) and make the threads as daemon threads..?
2. Should i write another application (offline application) runs out of server in another JVM ?
The following programs exist:
1. I have a java application which accepts bio potential data every second or two and stores it in the database. This is a socket server which accepts this data from multiple clients and spawns a new thread for processing it to store in the db.
2. I have a jsp page on tomcat server which reads historic client data from database (stored by application 1) and displays it on the page.
The socket server program in 1.) above is not running inside of tomcat server.The new requirement now is : Display all of the human data coming in live on the jsp page.Now the problem: I will now need to pass the live data from socket server (which is stand alone) to the jsp which is running on a tomcat server.
Possible solutions:
APPROACH 1: Run the socket server in the tomcat instead of stand alone and store the frequently incoming data in a java object so the jsp can access this object every second and display it on a graph.
PROBLEM : The stand alone java application does not need to be included in a tomcat server except for the fact that the jsp needs access to the live data. Also, I have read that this is not the best way.
APPROACH 2: Expose the stand alone java application as a web service and communicate with the jsp using REST architecture.
PROBLEM : The complication of using this method is that it will not have the flexibility offered by websockets or server sent events (SSE) of auto updating the latest data. The jsp will have to keep polling for new data every one second which is also not a very good option.
My dynamic web project has a java class that captures a session variable with the following code.
HttpSession LoginSession = request.getSession();
String VAR = LoginSession.getAttribute("myVar").toString(); //This is the row 127
If i test the app in local (Mac + Java 1.8 + Tomcat 8) all works. In my remote cloud server (Ubuntu 14.10 + Java 1.8 + Tomcat 8) all works, except this class, that has this code. I copy the complete error here. Note that the row 127 of the error message is the second row of the previous code; and, if i comment this row with // and assign a fix variable all works. So, the problem is that 127^ row.
14-Dec-2014 08:15:23.923 SEVERE [http-nio-8080-exec-14] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [srvNavigation.SrvPT] in context with path [/myapp] threw exception
java.lang.NullPointerException
at srvNavigation.SrvPT.doGet(SrvPT.java:127)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:618)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
[Code] ....
How can i solve the problem?
how to perform certain task on the shutdown of a web application in java
View Replies View RelatedI need to check in my java class the status of the javascript (whether it's enabled or disabled) and based on that few validations will be performed at server side.
If have to use noscript, then any small example for xhtml. My project works on Spring web flow.
i have file index.jsp , that approach to reguar java class and call function . in that function i want to get attribute from session like this :
List<Coupon> couponsList = (List<Coupon>)request.getSession().getAttribute("listOfCouponsThatNotExpired");
because this regular java class i get error message ,how to solve this ?
// MY login.jsp class
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<jsp:useBean id="person" scope = "request" class = "com.za.tutotial.mvc.PersonBeanModel"/>
[Code] ....
I had a Rest web service call and get InputStream.Now i want to Write Input Stream to PrintWriter of servlet.So that it can be downloaded.I am able to write String and file can be downloaded using following code, i want it to work for Input streamFollowing is code:
response.setContentType("application/x-download");
response.setHeader("Content-Disposition", "attachment; filename="" + name + ".pdf"");
response.getWriter().write(is);
Write can take following:
write(String)
write(char[])
write(int)
write(String, int len, int off)
write(char[], int len, int off)
I think char[] will not harm PDF file which is going to download in it
I just want to know how to pass an Attribute along with its value from servlets to a plain Java class. Im using java beans but it's showing null...So as an alternative im using session to access variables in java class..
View Replies View RelatedWe have two servlets application running on same server with Java EE 6 with below mention application URL.
Servlet1 Application URL: http://<severname>/*servlet1*
Servlet2 Application URL: http://<severname>/*servlet2*
My question is how to call Servlet2 from Servlet1 with Post method without using server name. May be something like this:
servlet.invoke(servlet2).
I need to write server side program(Servlet) which must be access by several requests at same time.how to handle this using java? Do i need to use queue or multiple instance of same class. Any example server method which returns the results based on ID
public String getResut(int id){
1)get db connection
2)get the result from db
3) retun the result
}
How to upload file to google drive using java. my java code is.
HttpTransport httpTransport = new NetHttpTransport();
JsonFactory jsonFactory = new JacksonFactory();
GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(
httpTransport, jsonFactory, CLIENT_ID, CLIENT_SECRET, Arrays.asList(DriveScopes.DRIVE))
.setAccessType("online")
.setApprovalPrompt("auto").build();
[Code] ....
So in that file object(java.io.File fileContent = new java.io.File("document.txt");) asking complete file path. But in file upload we can get only file name not path.
I made a web app to test the ServletContextListener in tomcat according to the book head first servlets and jsps and used the code
out.println("test context attributes set by listener<br>");
Dog dog = (Dog) getServletContext().getAttribute("dog");
out.println("Dog's breed is: "+dog.getBreed());
in the listener class.But the output is showing the first line only and the second println() is not showing any output whereas my Dog class compiled successfully and I didn't see any NullPointerException as expected in the book but somehow it seems like the problem is in the 2nd line of code only but I don't know what.
I also tried to add a 4th line at the end with println() only but with a simple text even that is not running but when I put that same line after the 1st line, the output is shown.I am unable to see what has gone wrong in the 2nd line of code.
i am trying to do a program captures keystroke and mouseclick from user in a textarea and insert the details intoa text file using java. Mainly such as delay between keys, no. of times backspace being pressed, alt tab press and copy paste mouse click.
View Replies View RelatedIn my web application i want to upload file to drop-box. I am getting file name from browser.Is it possible to upload file to drop-box with only file name.
Below the drop-box upload code with java.
File inputFile = new File("New Text Document.txt");
System.out.println("inputFile.getAbsoluteFile(): " + inputFile);
FileInputStream inputStream = new FileInputStream(inputFile);
try {
DbxEntry.File uploadedFile = client.uploadFile("/magnum-opus.txt",
DbxWriteMode.add(), inputFile.length(), inputStream);
System.out.println("Uploaded: " + uploadedFile.toString());
} finally {
inputStream.close();
}
In the above code the place New Text Document.txt we have to provide total path of file.
I am trying to use iText to create a PDF document. I found a nice tutorial online but one thing stumps me. How do I get the URL of the JSP page that contains the content? Since this will not be static, I don't want to hard code this. I am sure this is something simple but I am fairly new to servlets and JSP.
String File_To_Convert = "test.htm";
How do I get the url of the JSP page?