How to parse a requested parameter String to a double (or self-made class)? : <p>So as part of an add form to a database I request a parameter form the form by the id (request.getParameter("idOfInput"), this gives me a String but the input is a price. I have to parse this input into a double and pass it on to my setPrice() method. However when I parse it I get a NullPointerException saying there is a Floating Decimal. How do I pass on my paremeter correctly? Also I have class named Category and I want to do the same for that.</p>

<pre><code>private void setPrice(Bike bike, HttpServletRequest request, ArrayList&lt;String&gt; errors){
    String priceS = request.getParameter("price");
    double price = Double.parseDouble(priceS);
    try{
        bike.setPrice(price);
    } catch (DomainException e){
        errors.add(e.getMessage());
    }
}
</code></pre>
