Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what is wrong with my jsp

 
Archana Annamaneni
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi ,
I have following jsp , it runs fine if i delete that if part, it prints the query string as null, i am getting errors becuse of that if , i am not undertsanding what is wrong with that part, someone please suggest.

<html>
<head>
<br>
<br>
<center>
<h2>Enter the following data</h2>
</center>
<br>
</head>
<body bgcolor="#FFDAB9">
<%
String query = request.getQueryString();
out.println("query is "+query);
if(query.equals("null"))
{
out.println("query is null");
}
%>
</body>
</html>
I ma getting folowing errors when i access it thorugh the browser
java.lang.NullPointerException
at org.apache.jsp.index_jsp._jspService(index_jsp.java:58)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:210)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
 
Archana Annamaneni
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey i got that , i have to use
if(query == null
{
}
 
toma lam
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cool!
Yeh, this gets me a lot too. I keep forgetting that Null isn't treated like an object, so you can't use the equals method.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic