Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JSP servlet bean bad communication  RSS feed

 
Antonino Lo Bue
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I'm new to servlets and JSP,
I've deployed into Tomcat 5.5 a servlets that creates a java object (I tried with String) and pass it to a JSP page using request.setAttribute(...) method...

where dispatch method is:


In the JSP I've:


After deploying Tomcat get this error:



I've been tried to change scope attribute from "request" to "session" without any change...



 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65830
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried your code in my own environment and it worked perfectly.

How are you initiating the request? Are you sure that the servlet is being invoked?

Your error is indicative that the JSP may be being invoked without the servlet.
 
Antonino Lo Bue
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've developed the servlet for use of Jess (Rule-engine) to import an ontology (from JessTab/Protege) and apply to this some inference rules...
the String is only for debug....because is much simpler than passing other bean...


Here is code:


BaseServlet class:
_____________


**********************
HyperContainer servlet class:
______________________


**************
hyperContainer.jsp :
______________



[ February 08, 2007: Message edited by: Antonino Lo Bue ]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65830
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
None of that answers my question. What URL are you using on the request?
 
Antonino Lo Bue
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know what you mean by "what URL".... I've the servlets deployed into Tomcat..
this is my web.xml conf file:

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65830
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Antonino Lo Bue:
I don't know what you mean by "what URL"....


The URL that is being used to initiate the request.
 
Antonino Lo Bue
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've this index html:



http://localhost:8005/servletHyperJessGen/hyperContainer.jsp
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65830
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Aha!

http://localhost:8005/servletHyperJessGen/hyperContainer.jsp

This directly addresses the JSP without the benefit of your controller being called in order to set up the scoped variable.

You need to use the appropriate URL to invoke your controller, not the JSP.
[ February 09, 2007: Message edited by: Bear Bibeault ]
 
Antonino Lo Bue
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok... but what is the appropriate URL???
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65830
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Think about it for a few minutes. You are setting up a servlet that creates a scoped variable and places it on the request. It then forwards to a JSP that expects to find that scoped variable.

But, you are directly addressing the JSP, hence cutting the servlet completely out of the picture. Naturally, the JSP complains. It's sort of like skipping ahead on an assembly line and wondering why all the parts you need aren't there.

Your URL needs to address the servlet, not the JSP.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65830
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hint, from your deployment descriptor:

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!