File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes problem in servlet !!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "problem in servlet !!!" Watch "problem in servlet !!!" New topic

problem in servlet !!!

ramakrishna pydipati

Joined: Oct 13, 2003
Posts: 23
hai everybody,
I tried to compile this servlet but I am getting this error,as shown below.
So please help me out.
code is://package bonus.controllers;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
* This servlet accepts user data and
* returns the bonus in a HTML page.
public class BonusCalculationServlet extends HttpServlet {
* This method will be called by the Servlet Container when
* this servlet is being placed into service.
* @param config - the <CODE>ServletConfig</CODE> object that
* contains configutation information for this servlet.
public void init(ServletConfig config) {
System.out.println("CalculateBonus: init()");
* This method calculates bonus based on the given
* input.
* @param multiplier - the multiplier to be used to
* determine the bonus.
* @param bonus - bonus amount to be multiplied.
* @return calculated bonus as a <CODE>double</CODE>.
public double calculateBonus(int multiplier, double bonus) {
// this method simply multiplies the input
// parameters and return the output
double calculatedBonus = (multiplier * bonus);
return calculatedBonus;
* This method handles the HTTP GET requests for this servlet.
* It calculates the bonus based on the data passed in the request
* and sends the bonus as a HTML page response.
* @param request - object that contains the request the
* client has made of the servlet.
* @param response - object that contains the response the servlet
* sends to the client.
* @exception - if an input or output error is
* detected when the servlet handles the GET request.
* @exception ServletException - if the GET request could not be handled.
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
// get the multiplier and the social Security number
// information from the request
String inputMultiplier = request.getParameter("multiplier");
String ssn = request.getParameter("ssn");
// convert the data from String form to integer form
Integer multiplierAsInteger = new Integer(inputMultiplier);
int multiplier = multiplierAsInteger.intValue();
// calculate the bonus using the BonusCalculator
double inputBonus = 100.00;
double bonus = this.calculateBonus(multiplier, inputBonus);
// write the response to be displayed
// set the response type
// obtain the writer to write the response
PrintWriter out = response.getWriter();
// write the page title
out.println("Servlet Example - Bonus Calculator");
// write the bonus information
out.println("<H1>Bonus Calculation:</H1>");
out.println("<P>Social Security Number: " + ssn + "<P>");
out.println("<P>Multiplier: " + multiplier + "<P>");
out.println("<P>Bonus Amount: " + bonus + "<P>");
// close the page
// close the writer
* This method will be called by the Servlet Container when this servlet
* is being taken out of service.
public void destroy() {
System.out.println("BonusCalculationServlet: destroy()");
The server encountered an internal error () that prevented it from fulfilling this request
java.lang.NumberFormatException: null
Chad McGowan
Ranch Hand

Joined: May 10, 2001
Posts: 265
What is the value for inputMultiplier? Is it a valid number?
Integer multiplierAsInteger = new Integer(inputMultiplier);
ramakrishna pydipati

Joined: Oct 13, 2003
Posts: 23
I appreciate u r response.
reg ing, number yes it is a valid number ex: I gave 47;
Chad McGowan
Ranch Hand

Joined: May 10, 2001
Posts: 265
Are you sure. Why don't you put a System.out.println("inputMultiplier = " + inputMultiplier) to see what the value is before you try to convert it to an Integer. You might be surprised.
It is sorta covered in the JavaRanch Style Guide.
subject: problem in servlet !!!
Similar Threads
Checking user selection
still running the old servlet
how to deploye EJB
unable to recognize jndi name when using myeclipse3.8.3
Using get() and post() together