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

Servlet strange?

 
Marshall satriana
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I have found some difficulties when i try to connect to EJB 2.0
I use servlet as client which provide some form input lets say 2 text field and 1 submit button.


the problem is when I execute the servlet directly..there is error which indicate Null Exception. when I omit code for accessing bean from bean, the problem doesnt appears.Since I want to connect to EJB so I do it input form based HTML. The problem doesnt appear either.
My question is why servlet detect null exception since i already protect from null with else condition. Is it true that servlet cannot include <form> in its body? Any solution from everyone since I still wanna doing <form> inside servlet.

Thanks, Regrd,
Satriana

 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I do not think that I understand your question fully but here is what I think,
As you have mentioned that if you remove the bean part of the code you do not get any exception , then I guess that home or bean in the below mentioned code might be null.Can you print the complete stack trace.

AccessBeanHome home=lookupbeanhome();
AccessRemote bean=home.create();
String name=bean.getName();

Why do not you do the stuff in the following manner for cleaner implementation.

Make a HTML to submit data to a servlet.The servlet would get the data and execute the remote method , mean invoking the bean with the input data and then set the reply from the invocation into a bean and set the bean in the request scope and forward it to result jsp .The result jsp might use the bean set in request for displaying the values to the user.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic