Is there a bug in Serlvet API?
Hi, this (simplified) code will not run. It seems that some of the variable could not be passed on to the function Quanto_Calc(). If I set Output=S, if works fine and gives me the expected number. but for Output=FX ; or some of the other parameters, it simply would not work. Yet the redirect >response.sendRedirect("http://www.derivativesmodels.com/DerivativesModels/Equity.php3?Asset="+S+"&FormFlag=QTO"+"&FX="+FX+"&Correlation="+corr+"&FXVolatility="+vol_FX*100+"&ForeignRate="+r_for*100+"&PutCall="+PutCall+"&sStyle="+sStyle+"&Strike="+X+"&Volatility="+v*100+"&Maturity="+T+"&Rate="+r*100+"&Output_price="+price+"&Dividend="+D*100); < manages to return all the correct variables. Where has it gone wrong?
import java.io.*;
import java.math.*;
import java.text.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class DM_Servlets_QTO extends HttpServlet
{
double S,X,r,v,T,D,P, vol_FX, r_for, FX, corr, OptionPrice, diff, Vega, dv, error, InputPrice,Output;
String sPutCall, sStyle, PutCall;
Double inter_str;
DecimalFormat df= new DecimalFormat("0.#####");
int Graph_nodes;
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
PutCall=request.getParameter("PutCallFlag");
String Temp_delta, Temp_gamma, str;
double price1, price2, price3, price4;
if (PutCall.equals("C"))
sPutCall="EuropeanCall";
else if (PutCall.equals("P"))
sPutCall="EuropeanPut";
str=request.getParameter("Asset");
inter_str= Double.valueOf(str);
S = inter_str.doubleValue();
str=request.getParameter("Strike");
inter_str= Double.valueOf(str);
X = inter_str.doubleValue();
str=request.getParameter("FXVolatility");
inter_str= Double.valueOf(str);
vol_FX = inter_str.doubleValue()/100;
str=request.getParameter("FX");
inter_str= Double.valueOf(str);
FX = inter_str.doubleValue();
str=request.getParameter("Correlation");
inter_str= Double.valueOf(str);
corr = inter_str.doubleValue();
str=request.getParameter("Volatility");
inter_str= Double.valueOf(str);
v = inter_str.doubleValue()/100;
str=request.getParameter("Rate");
inter_str= Double.valueOf(str);
r = inter_str.doubleValue()/100;
str=request.getParameter("ForeignRate");
inter_str= Double.valueOf(str);
r_for = inter_str.doubleValue()/100;
str=request.getParameter("Maturity");
inter_str= Double.valueOf(str);
T = inter_str.doubleValue();
str=request.getParameter("Dividend");
inter_str= Double.valueOf(str);
D = inter_str.doubleValue()/100;
double price=Quanto_Calc(sPutCall, FX, corr, S, X, r, r_for, D, v, vol_FX,T);
response.sendRedirect("http://www.derivativesmodels.com/DerivativesModels/Equity.php3?Asset="+S+"&FormFlag=QTO"+"&FX="+FX+"&Correlation="+corr+"&FXVolatility="+vol_FX*100+"&ForeignRate="+r_for*100+"&PutCall="+PutCall+"&sStyle="+sStyle+"&Strike="+X+"&Volatility="+v*100+"&Maturity="+T+"&Rate="+r*100+"&Output_price="+price+"&Dividend="+D*100);
}
double Quanto_Calc(String sPutCall, double FX, double corr, double S, double X, double r_dom, double r_for, double D, double vol, double vol_FX, double T)
{
Output=FX;
return Output;
}
}

