Null pointer fix when print servlet url to address bar