Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Servlet strange?

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,

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.
Catch Ernie! Catch the egg! And catch this tiny ad too:
Thread Boost feature
    Bookmark Topic Watch Topic
  • New Topic