I have a controller
servlet that will accept one of two different parameters depending on which hyperlink summons it.
Ex. <A HREF="Genre?genreID=3">Rock</A>
<A HREF="Genre?ID=4">AC/DC</A>
Here, Genre is the servlet and genreID and ID are the two different parameters. Every time a link is used, only one parameter is sent. They are both integer parameters.
My problem is right now I start my Genre servlet by reading in both of those parameters as such:
int genreID = Integer.parseInt(request.getParameter("genreID"));
int ID = Integer.parseInt(request.getParameter("ID"));
However just using this in my servlet causes an error during runtime. I suppose I cannot read in a value if it has not been assigned a value?? How can I solve this problem??
Basically because this is a controller servlet I want it to be able to handle multiple similar requests. In this example, if it receives a genreID, then it retrieves a whole category of music. If an ID is received, it retrieves just one cd.
Thanks to all who reply!!