my dog learned polymorphism*
The moose likes JSP and the fly likes Error In JSP Page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Error In JSP Page" Watch "Error In JSP Page" New topic
Author

Error In JSP Page

Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
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

Joined: Oct 20, 2007
Posts: 50
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.


Free Mock tests Interview questions
Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
That didn't work! Providing the whole JSP for a better view of the error!

Smitha H Rao
Ranch Hand

Joined: Oct 20, 2007
Posts: 50
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

Joined: Mar 04, 2009
Posts: 477
Thanks a lot Smitha! It worked!
Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
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

Joined: Aug 18, 2009
Posts: 15
Form action has to be relative, Not absolute.

because in <url-pattern> you said:

Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9293
    
  17

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...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
My code is:

Smitha H Rao
Ranch Hand

Joined: Oct 20, 2007
Posts: 50
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

Joined: Nov 06, 2000
Posts: 177
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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Error In JSP Page