Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error In JSP Page

 
Somnath Mallick
Ranch Hand
Posts: 483
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Everyone,

I have am facing an error in a JSP page. Could you please let me know what the problem is because it seems quite all right to me!


I get this when i another jsp page on the server and from that JSP page the request comes to a servlet from which the request is forwarded to this JSP page!
 
Smitha H Rao
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the line 17 should be like below if you want to print cpDetails.get("CP_NAME") 's value.

<td ><%= cpDetails.get("CP_NAME") %></td>

Also make sure your JSP page know what cpDetails object is.

 
Somnath Mallick
Ranch Hand
Posts: 483
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That didn't work! Providing the whole JSP for a better view of the error!

 
Smitha H Rao
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might get exception if your cpDetails is null.

Try something like this.
<%= (cpDetails!=null?cpDetails.get("CP_NAME"):"null") %>


Thanks
Smitha
 
Somnath Mallick
Ranch Hand
Posts: 483
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Smitha! It worked!
 
Somnath Mallick
Ranch Hand
Posts: 483
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have another small Query! Please help me in on this one! I would like you to see my web.xml file. I want a JSP page to forward the request to a servlet but I always get the error



web.xml:


My form tag consists of:


The problem is the request is not forwarded to the servlet from the JSP. Could you please let me know what to put in the "action" attribute of the form tag?
 
mark benz
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Form action has to be relative, Not absolute.

because in <url-pattern> you said:

 
Ankit Garg
Sheriff
Posts: 9521
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your form action doesn't need to have the full path of the requested servlet starting from the protocol. You can write /EnvironmentDetails/EnvDetailsServlet only. And as far as the error goes, did you override the doPost method in your servlet. It would be helpful if you showed us the the servlet code...
 
Somnath Mallick
Ranch Hand
Posts: 483
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My code is:

 
Smitha H Rao
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is nothing wrong with the web.xml entry

in form <form action="<%=request.getContextPath()%>/EnvDetailsServlet" method="post">

This will solve the problem.
 
Max Rahder
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Smitha H Rao wrote:You might get exception if your cpDetails is null.
Try something like this.
<%= (cpDetails!=null?cpDetails.get("CP_NAME"):"null") %>


I would change your controller so cpDetails is guaranteed to be non-null. I.e., it should always reference a Map, although the Map could be empty.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic