Question

In the snippet of code below, I'm using a class to get a reference to an instance of BookList. This class has a getBook() method which returns an instance of a Book from a String representing an isbn code. The instruction is run in the doGet() method of a HttpServlet.

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {  
Book book = GlobalVar.bookList.getBook( request.getParameter("isbn") );
//
}

What potential problems do you see in using shorthand notation in this context ?

P.S: The Global class is going to be replaced with a ServletContext.

Was it helpful?

Solution

I would say NullPointerExceptions. What happends if the client, doing the HTTP GET request, has no paramated named "isbn". Is the getBook implemented in way that it supports null as an argument?

OTHER TIPS

The request may not have a parameter "isbn".

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top