Originally posted by Harpal Singh:
Dear Sachin,
Can u post ur code so that i can see what is wrong???I am sure something to do with doGet or doPost method.....
Harpal
dear sir,
the code goes here
i have used method post on html page and doPost in servlet
===============
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.sql.*;
import sun.net.smtp.*;
public class sanquotdhootgroup extends HttpServlet{
static Connection conn;
String Ph=null,Std,Phone,FName,LName,City,State,Email,Add1,Add2,Address;
String Zip,BuyFrom,Model,Color;
Statement stmt;
ResultSet rs;
int GodownCost=0,Registration=0,TotalCost=0,Insurance=0;
public void doPost(HttpServletRequest req,HttpServletResponse resp)throws ServletException,IOException
{
resp.setContentType("text/html");
PrintWriter out=new PrintWriter(resp.getOutputStream(),true);
out.println("<html>");
out.println("<head>");
out.println("<title>Dhoot Motors</title>");
out.println("</head>");
out.println("<body>");
out.println("<font size=3>");
FName=req.getParameter("FName");
LName=req.getParameter("LName");
City=req.getParameter("City");
State=req.getParameter("State");
Std=req.getParameter("Std");
Phone=req.getParameter("Phone");
Add1=req.getParameter("Address1");
Add2=req.getParameter("Address2");
Email=req.getParameter("email");
Zip=req.getParameter("Zip");
BuyFrom=req.getParameter("BuyFrom");
Model=req.getParameter("Model");
Color= req.getParameter("Color");
Address=Add1+" "+Add2;
Ph="("+Std+")"+Phone;
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn=DriverManager.getConnection("jdbc
dbc:ditl","ditl","ditl");
stmt=conn.createStatement();
String q="insert into NewSantroQuot (FName, LName, EMail, Phone, City, Zip, State, BuyFrom, Model, Address,Color) values('"+FName+"','"+LName+"','"+Email+"','"+Ph+"','"+City+"','"+Zip+"','"+State+"','"+BuyFrom+"','"+Model+"','"+Address+"','"+Color+"')" ;
String q1="select GodownCost,Insurance,Registration from OutSantroCost where Model='"+Model+"'AND Color='"+Color+"'";
String q2="select GodownCost,Insurance,Registration from InSantroCost where Model='"+Model+"'AND Color='"+Color+"'";
stmt.executeUpdate(q);
if (BuyFrom.equals("Ex_Showroom"))
{
rs=stmt.executeQuery(q2);
while(rs.next()){
GodownCost=Integer.parseInt(rs.getString(1));
Insurance=Integer.parseInt(rs.getString(2));
Registration=Integer.parseInt(rs.getString(3));
}
}
else
{
rs=stmt.executeQuery(q1);
while(rs.next()){
GodownCost=Integer.parseInt(rs.getString(1));
Insurance=Integer.parseInt(rs.getString(2));
Registration=Integer.parseInt(rs.getString(3));
}
}
TotalCost=GodownCost+Registration+Insurance;
out.println("<font size=4 color=\"red\"><b>Dhoot Motors Ltd</b></font>");
out.println("<br>Dhoot Compound , Adalat Road");
out.println("<br>Aurangabad 431005");
out.println("<br>Phone : 338855,338855");
out.println("<hr>");
out.println("<table cellspacing=3>");
out.println("<tr><td><font color=blue><b> Thanks for the Quotation</font><font color=red> "+FName+" "+LName+"</b></font></td></tr>");
out.println("<tr></tr><tr></tr><tr><td bgcolor=#dfdfdf>Model </td><td bgcolor=#dfdfdf>Santro "+Model+"</td></tr>");
out.println("<tr><td bgcolor=#dfdfdf>Color</td><td bgcolor=#dfdfdf>"+Color+"</td></tr>");
out.println("<tr><td bgcolor=#dfdfdf>Vehicle Cost</td><td bgcolor=#dfdfdf>"+GodownCost+"</td></tr>");
out.println("<tr><td bgcolor=#dfdfdf>Insuarence Cost</td><td bgcolor=#dfdfdf>"+Insurance+"</td></tr>");
out.println("<tr><td bgcolor=#dfdfdf>Registration Cost</td><td bgcolor=#dfdfdf>"+Registration+"</td></tr>");
out.println("<tr><td bgcolor=#dfdfdf><b>Total Price </b></td><td bgcolor=#dfdfdf >"+TotalCost+"</td></tr>");
out.println("<tr></tr><tr><td bgcolor=#dfdfdf><font color=blue> Terms & Condition :</font></td></tr> ");
out.println("<tr><td bgcolor=#dfdfdf>Purchase to be made : "+BuyFrom+"</td></tr>");
out.println("<tr><td bgcolor=#dfdfdf> This Quotation is not valid without authorised signature.</td></tr> ");
out.println("<tr><td bgcolor=#dfdfdf> Quotation is valid for 30 days</td></tr> ");
out.println("<tr><td bgcolor=#dfdfdf> Quotation is valid within Aurangabad jurisdiction</td></tr> ");
out.println("<tr><td bgcolor=#dfdfdf> Delivery of the car depends on the availability</td></tr> ");
out.println("<tr><td bgcolor=#dfdfdf> We Provide 3 year extended warranty</td></tr> ");
out.println("<tr><td><font color=blue><b>Thanks for visiting this site</b></font></td></tr></table><body></html>");
}
catch(Exception sq)
{
out.println("Error : "+sq);
}
}
out.flush();
out.close();
}
}
====================
sachin
[This message has been edited by sachin dabhade (edited May 16, 2001).]
[This message has been edited by sachin dabhade (edited May 17, 2001).]