File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes Servlet strange? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Servlet strange?" Watch "Servlet strange?" New topic
Author

Servlet strange?

Marshall satriana
Greenhorn

Joined: Sep 12, 2007
Posts: 1
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

Joined: Nov 29, 2005
Posts: 2308
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.


Rahul Bhattacharjee
LinkedIn - Blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Servlet strange?