This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
The usual problem with this kind of shortcut appears when getParameter("id") returns null rather than the expected String and you get a null pointer exception.
Therefore, try to recover the parameter String first, test for null and then decide what to do.
Joined: Jan 05, 2013
Further to bills observation, any time you are dealing with objects such as requests it is good and advised practise to check for null first.
Including null checks is a good habit to get into in any code as it makes it more robust and also scales better... a few years down the line a joe bloggs decides to come along and use one of your methods then kindly passes a null value and.... POP.