Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Error In JSP Page

 
Ranch Hand
Posts: 483
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot Smitha! It worked!
 
Somnath Mallick
Ranch Hand
Posts: 483
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Form action has to be relative, Not absolute.

because in <url-pattern> you said:

 
Sheriff
Posts: 9690
42
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My code is:

 
Smitha H Rao
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Of course, I found a very beautiful couch. Definitely. And this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic