• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

JavaBean Component in jsp running in Weblogic Server

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
dear all,
so far i have covered Database , EJB access in servelet.in this thread i am going to give you example for JavaBean used in jsp page running under weblogic server.


-------------------------------------------------------------------------------------------------------------

JavaBean Class code(jspBeanTest.java)
package example;
import java.io.Serializable;
public class jspBeanTest
implements Serializable{
private String size = "Medium";
public void setSize(String size){
this.size = size;
}//end setSize()
public String getSize(){
return size;
}//end getSize()
public String exposedMethod(){
return "The size is " + size;
}//end exposedMethod()
}//end class jspBeanTest

-----------------------------------------------------------------------------------------------------
JSP page code(size.jsp)
<html>
<body>
<P>Examplep<BR><BR>
<P> Create or locate an instance of the<BR>
bean named:<BR><BR>
example.jspBeanTest.
<jsp:useBean
id="theBean"
scope="page"
class="example.jspBeanTest" />
<P>Display default size property of the <BR>
bean using the getter mehod.<BR><BR>
<%= theBean.getSize() %>
<P>Set the size property of the bean to<BR>
Large using the setter method.<BR><BR>
<% theBean.setSize("Large"); %>
<P>Get and display the size property<BR>
again using the getter method.<BR><BR>
<%= theBean.getSize() %>
<P>Invoke an exposed method on the bean.
<BR><BR>
<%= theBean.exposedMethod() %>
<P>Have a good day.
</body>
</html>

----------------------------------------------------------------------------------
deployment
1. create Directory structure like this :
App root -
-\WEB-INF
-\classes
-\example
2.put your compile class file of JavaBean in example directory.
3.put your jsp file in root directory.as jsp does not required entry in deployment desc. your work is over.

---------------------------------------------------------------------------------
run the server and type in address bar :
http://hostname:7001/size.jsp
bye
bharat
SCJP2
 
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What a daily treat!!!
 
I'm thinking about a new battle cry. Maybe "Not in the face! Not in the face!" Any thoughts tiny ad?
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic