Contact Us
  
 
 
    SearchSearch   RegisterRegister   Log inLog in 

Accessing JavaBean in servlet or servlet in javaBean.

Accessing JavaBean in servlet or servlet in javaBean.

 
Post new topic   Reply to topic     Forum Index -> Java,Struts framework, Velocity, JSF, Hibernate, Servlet, JSP, javaBeans
View previous topic :: View next topic  
Author Message
sumitkondal



Joined: 12 Jan 2007
Posts: 1

PostPosted: Sun Jan 14, 2007 2:09 pm    Post subject: Accessing JavaBean in servlet or servlet in javaBean. Reply with quote




Hi.
i m software developer, but i m new to development. Please can anyone tell me how to access or get javaBean in servlet or vise versa. i have a class and that is javabean. i made some methods in that javabean. now i want to use that bean in servlet. But i dont know how to do that .
Back to top
View user's profile Send private message
javatech



Joined: 19 Jan 2007
Posts: 39

PostPosted: Fri Jan 19, 2007 8:19 am    Post subject: Accessing JavaBean in servlet or servlet in javaBean. Reply with quote

This can be done by creating object of that class, which class you want to access.

for this you have to do

Quote:
import yourpackage.ClassName
e.g import com.ind.model.JavaBean;



Then you have to create object of this class in your servlet or any class

Code:


   JavaBean jb= new JavaBean();
   
      jb.YourMethod();
 

if you want to store it
jb.YourMethod in any data type you can store it now
like

String jbData=jb.YourMethod();
you have to type cast your objects

mean what is return type of your YourMethod() string or integer any
String jbData=(String)jb.YourMethod();


Hope this will help you dear
Back to top
View user's profile Send private message
javatech



Joined: 19 Jan 2007
Posts: 39

PostPosted: Sun Dec 07, 2008 1:04 pm    Post subject: Reply with quote

Access javabean in servlet can be by class object instantiated

Code:
ClassName objectName= new ClassName();
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Java,Struts framework, Velocity, JSF, Hibernate, Servlet, JSP, javaBeans All times are GMT
Page 1 of 1

 
Jump to:  
  Quick Post a Reply Topic
     
  Name (required)  
     
  Email Address (will not be published) (required)  
     
  Subject of topic (required)  
     
   
     
   
     
  Advertisement  
     
 
     


  More Links  
 
JSP Introduction
JSP Setup
Simple JSP Example
JSP Variable
Array Declaration in JSP
JSP Forms and User Input
Form Validation
JSP Cookies
JSP Session Object
Loop, content collection, iterator, conditional check in JSP
JSP Application Object
JSP Include
JSP Response Object
JSP Request Object
JSP Error Handling
JSP File Handling Object
JSP Action Tag
JSP Implicit Objects
JSP Declaration
JSP Directive
JDBC Introduction
JDBC Driver
JDBC Connection
JDBC Prepared/Statement
JDBC ResultSet
JDBC Close Connection object
JDBC Insert
JDBC Display Records
JDBC Update
JDBC Delete
JDBC Sorting
JDBC Query
JDBC Exception
JDBC Add Batch
JDBC Transaction/RollBack