how do i solve the double method while string in java with servlet


import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class UserControll extends HttpServlet
    private static final long serialVersionUID = 1L;
    private static String INSERT_OR_EDIT = "/user.jsp";
    private static String LIST_USER = "/listEmp.jsp";
    private UserDao dao;

    public UserControll() {
      UserDao dao = new UserDao();

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String forward="";
        String action = request.getParameter("action");

        if (action.equalsIgnoreCase("delete")){
            int Employee_Id= Integer.parseInt(request.getParameter("Employee_Id"));
            forward = LIST_USER;
            request.setAttribute("users", dao.getAllUsers());    
        } else if (action.equalsIgnoreCase("edit")){
            forward = INSERT_OR_EDIT;
            int Employee_Id = Integer.parseInt(request.getParameter("empId"));
            User user = dao.getUserById(Employee_Id);
            request.setAttribute("user", user);
        } else if (action.equalsIgnoreCase("listUser")){
            forward = LIST_USER;
            request.setAttribute("Employee", dao.getAllUsers());
        } else {
            forward = INSERT_OR_EDIT;

        RequestDispatcher view = request.getRequestDispatcher(forward);
        view.forward(request, response);

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        User user = new User();
        user.setSalary(request.getParameter("empsalary"));// here is my error..i declared salary is double
        try {
            Date dob = new SimpleDateFormat("MM/dd/yyyy").parse(request.getParameter("empdob"));
        } catch (ParseException e) {
        user.setActive(request.getParameter("empactive"));// here is my error.. i declared active is boolean
        String empid = request.getParameter("empid");
        if(empid == null || empid.isEmpty())
            user.setEmployee_ID(Integer.par`enter code here`seInt(empid));
        RequestDispatcher view = request.getRequestDispatcher(LIST_USER);
        request.setAttribute("users", dao.getAllUsers());
        view.forward(request, response);


The getParameter() method of HttpServletRequest is inherited from ServletRequest. From the API docs you can see this method always returns a string. You need to parse your boolean or double from this string, for example


Need Your Help

Creating has_many relationships in ActiveRecord without :primary_key

ruby activerecord

I'm working with an older version of Rails and ActiveRecord that does not have the :primary_key option in has_many relationships of more recent ActiveRecord versions and unfortunately I don't get to

popup box should not close if user having error in their signup form

javascript php jquery ajax forms

This php coding is showing the error message correctly. But, my problem is that popup box does not hold on if the registration form having error. For example, if you click a link one popup box will...