What are Java Beans?

Can someone tell me what they do please?
Saple codes might help too

Here's a simple Java Bean:
import java.io.Serializable;
public class SampleBean implements Serializable
    private static final String DEFAULT_MESSAGE = "Do a Google search on 'Java Beans next time'";
    private String message;
    public SampleBean() { this(DEFAULT_MESSAGE); }
    public SampleBean(final String message) { this.message = message; }
    public String getMessage() { return this.message; }
    public void setMessage(final String newMessage) { this.message = newMessage; }
}Do a Google search to learn more. Sun has Java Bean tutorials.

Similar Messages

  • WHAT ARE JAVA SERVER PAGES?

    Right now I am learning java on my own, and I have a question.
    What are Java Server Pages(JSP)?
    Thanks

    In short, they're standard HTML pages with embedded Java code to dynamically create pages based on values from the user, a database, or some other source. Search the java.sun.com site for a more detailed explanation, and examples too. Or, pick up a book.

  • What is java beans?

    what is the difference between java application and java beans?
    thanks!

    Hmm, I'm gonna have a go at this - hopefully someone will build on it with more differences or requirements:
    A Java Bean is merely a Java class written to conform to some simply rules for construction and method naming eg:
    public class MyBean
      private String myField;
      public MyBean()
      public void setMyField(String myField)
        this.myField = myField;
      public String getMyField()
        return myField;
    }Applications can use Java Beans without having to know about the class in advance - a typical situation might be their use in visual GUI editors where the properties of the bean can be exposed and manipulated by the editor through examination of the method names or an accompanying descriptor.
    An Enterprise Java Bean doesn't have all that much in common with a Java Bean. An EJB is a small set of classes meeting a single (usually) business requirement written to conform to the EJB specification. This enables them to be used by J2EE Application servers to perform enterprise business functions (data storage, manipulation, business logic etc.). The whole idea is that by writing to the specification the server can automatically provide support for transaction management, concurrent access, scaleability, etc that a mission-critical system might require without the programmer having to understand the workings of the application server.
    Essentially an EJB can either
    1) maintain the permanent state of a business object (eg, hold the data for a single product in a catalogue)
    2) perform a small set of business operations (eg, place an order for a customer)
    3) act in response to messages passed around the system (eg, send a mail to the user when the items have been shipped)
    I would have a look at the following two pages to get a better overview:
    http://java.sun.com/products/javabeans/
    http://java.sun.com/products/ejb/
    Hope this helps.

  • What are JAVA API are threaded in default list plz

    hi every body
    Can u give me List of JAVA API are threaded default

    Can u give me List of JAVA API are threaded default1. Java is not an abbreviation.
    2. What do you mean?

  • Java Beans Invironment

    salam to all
    please help me to learn java beans. i need to know what is java beans invironment?
    and we need to know how can i compile and run a java beans program?
    i hope to send a simple program to learn java beans
    salam

    salam to all
    please help me to learn java beans. i need to know what is java beans invironment?All you need to compile and run Java Beans is the JDK. There used to be a Sun product called the Bean Box, but I don't think anyone uses it now.
    and we need to know how can i compile and run a java beans program?Compile using javac.exe; run using java.exe
    i hope to send a simple program to learn java beansGive this a look:
    http://java.sun.com/developer/onlineTraining/Beans/JBeansAPI/shortcourse.html
    salam

  • Java Beans requirement

    Hi everybody,
    I want to use java beans to make code reusability, but I need arguments to explain their benefits so I need to be more informed about:
    - what using java beans demand in terms of technical tools
    - and whatever can help me to present their benefits
    I am also all ears for whatever you think usefull in this case
    thanks a lot in advance

    No, using java beans does not require you to use any tools. Any java bean can be called like any other java class.
    The benefit is if you use java beans, you can make use of tools to reduce your development time, and the code you write will be more reusable because it handles change better.

  • Diff between java beans and EJB

    What is Java Bean

    http://www.google.co.uk/search?hl=en&q=What+is+Java+Bean&btnG=Google+Search&meta=

  • Example for java bean

    Hi,
    can someone please tell me what a java bean is and show me a very basic example using a java bean.
    Thanks in advance for any replies
    Jim.

    When ever I have questions like this "Tutorial" just screams though my mind, take a look, it is exactly what you want:
    http://java.sun.com/developer/onlineTraining/Beans/

  • User parameter are not show in database using Servlet and java Bean

    Hello Sir,
    when I insert the parameter in run time, weblogic server and JSP show that parameter are saved.
    Allthough row increment in database but they not show in database.
    Here My Code:
    login.html:
    <html>
    <head>
    <title>A simple JSP application</title>
    <head>
    <body>
    <form method="get" action="tmp" >
    Name: <input type="text" name="user">
    Password: <input type="password" name="pass">
    <input type="Submit" value="Submit">
    </form>
    </body>
    </html>LoginServlet.java:import javax.servlet.*;
    import javax.servlet.http.*;
    public class LoginServlet extends HttpServlet{
    public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException{
    try
    String user=request.getParameter("user");
    String pass=request.getParameter("pass");
    co.SimpleBean st = new co.SimpleBean();
    st.setuserName(user);
    st.setpassword(pass);
    request.setAttribute("user",st);
    request.setAttribute("pass",st);
    RequestDispatcher dispatcher1 =request.getRequestDispatcher("submit.jsp");
    dispatcher1.forward(request,response);
    catch(Exception e)
    e.printStackTrace();
    }SimpleBean.java:
    package co;
    import java.util.*;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    import java.util.*;
    public class SimpleBean {
    private String user="";
    private String pass="";
    private String s="";
    public String getuserName() {
    return user;
    public void setuserName(String user) {
    this.user = user;
    public String getpassword() {
    return pass;
    public void setpassword(String Pass) {
    this.pass= pass ;
    public String issueData()
    try
    System.out.println("Printed*************************************************************");
    Class.forName("oracle.jdbc.driver.OracleDriver");
    System.out.println("Connection loaded");
    Connection con=DriverManager.getConnection("jdbc:oracle:thin:@VijayKumar-PC:1521:XE","SYSTEM","SYSTEM");
    System.out.println("Connection created");
    PreparedStatement st=con.prepareStatement("insert into vij2 values(?,?)");
    System.out.println("~~~~~~~~~~~~~~~~~~~~");
    String NAME=getuserName();
    st.setString(1,NAME);
    String PASSWORD=getpassword();
    st.setString(2,PASSWORD);
      st.executeUpdate();
    System.out.println("Query Executed");
    con.close();
    s=  "Your logging is saved in DB ";
    System.out.println("Your logging is saved in DB *****************");
    return(s);
    catch(Exception e)
    e.printStackTrace();
    return "failed";
    }submit.jsp:This is Submit page
    <jsp:useBean id="st" class="co.SimpleBean"/>
    <jsp:setProperty name="st" property="*" />
    <jsp:getProperty name="st" property="userName" /> <br>
    <jsp:getProperty name="st" property="password" /> <br>
    <% st.issueData();%>
    <%
    out.println("Ur data is saved in DB");
    %>Please Help me.
    Thanks.

    Ok, this seems to be a long and convoluted path to do absolutely nothing.
    You submit the form.
    You run a servlet that gets the parameters correctly (good), creates a SimpleBean (good) and then sets this into request attribute space under the names "user" and "pass" - (why?)
    You then forward to the jsp: submit.jsp.
    Submit.jsp creates a new SimpleBean, and attempts to populate it with <jsp:setProperty>. You then call the issueData method on it.
    Your complaint: Rows are being created in the database which have empty string values instead of the parameters you have passed.
    So, why are the values blank? Where do you think these values should be coming from?
    Looking at SimpleBean we find one mistake - you have mis-named your get/set methods.
    To properly follow java beans standards, you should use camel-case for your methods.
    Rather than getuserName() the method should be getUserName(). getpassword() should be getPassword() etc etc.
    The method getUserName() defines a property "userName" for the bean.
    Once that is fixed, lets go to submit.jsp. The <jsp:setProperty> statement will try and set all properties of the bean from the request parameters.
    There are no request parameters "userName" or "password" so those values don't get set in the bean, therefore it uses their default value of empty string - "".
    There ARE request parameters called "user" and "pass" but because they aren't properties of the bean, they get ignored.
    As a result, the values are empty string, and that is exactly what gets inserted into the database.
    Ways to fix this
    1 - rename your parameters on your form to be "userName" and "password" to match the bean. That way the <jsp:setProperty> tag will populate them properly.
    or
    2 - Call issueData() method from your servlet after you have created the SimpleBean. Better in my opinion as you then don't have any scriptlet code on a JSP page.
    Cheers,
    evnafets

  • What are JSP, Servlet , Bean in MVC ??..how does it function?

    suppose there's a bean file (.java) consisting of SQL query, and a servlet (.java) used to show an image, and lastly a jsp page when clicked shows the image.............can you please explain how does this work,how the logic flows,what happens step by step.....i really need to understand this, thankz.

    A JSP page is essentially an easy way to create an abstract behind the scenes servlet where its whole purpose is to serve HTML. JSP tags and java code within the page are processed on the server side first and then a response is sent containing the HTML.
    The JSP can send its request to another handler or servlet that can do the processing.
    I don't understand where a java bean comes into play in this situation.

  • What are the pre-requisite for JAVA Proxy communication?

    What are the pre-requisite for JAVA Proxy communication?

    Hi,
    You can install the Java proxy runtime on the SAP J2EE Engine Release 6.40 SP5 or higher.
    The messaging system that the Java proxy runtime uses to send messages to the Integration Server must also be installed on the J2EE server.
    To send messages from a J2EE application, the application must be programmed against beans that encapsulate all details about the Java runtime. The following classes are generated:
    ·        Proxy classes that send or receive messages using the Java proxy runtime.
    ·        Bean classes as an outer shell that conform to the J2EE standard. The beans call the proxy classes for communication.
    The classes must be deployed on the J2EE server together with their J2EE application
    see this link for the example scenario http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/f272165e-0401-0010-b4a1-e7eb8903501d

  • I have this idea...  Browser inside a java bean area

    10G forms
    As I see questions pop up in this forum I notice that people want to do some of the same things in forms that one can do in a browser. Like Flash.. Or play a movie. Since, Im not a java expert, I have this thought, and would like any Java Bean experts to respond. I am not afraid to write Java code and will attempt to write this myself if it sounds feasible. I just need a "go for it" or "it sounds good" from some knowledgable forms/java developers.
    So.. Heres what I want to do...
    Basically why can't we as forms developers create a java bean area and open the default browser of the client inside the area? If we can do that then we can display flash, play a movie, run an oracle report inside a form? Cant we? We could then do whatever the browser can do inside a form java bean area?
    Here is my requirement that makes me want to do this...
    The requirement is "Can you display the output of an Oracle Report inside of a oracle form?" The users do not want the report output in a separate window. They want to surround report with form fields. An operater will look at the report in the center of the form, interpret hand written text (image), and update the form fields around the report with correct values. This report is very complicated. It converts xml and also converts base64 encoded images to jpegs overlaying these values on another large image of a state police form. Since this report already does all of this, we would like to just display the report output inside the form and not rewrite the whole thing so a form can do it too.
    Comments are appreciated..
    Im actually hoping Francois gets intriqued way over there in Paris as he sometimes does with these java questions :)
    Message was edited by:
    Mark Reichman

    I've seen an example that shows how to embed MS-Word within an applet, using OLE automation, so I suspect that doing this with Internet Explorer could be achieved. It's an interesting example, called Snippet157 -- part of the Eclipse project. It also demonstrates using the SWT-AWT bridge, whose purpose is to allow AWT and SWT components to be used together. You don't need Eclipse to run the snippet, but you would need to download SWT from http://www.eclipse.org/swt (the SWT-AWT bridge is included.) Whether this example could be adapted to pure Swing/AWT, and how easily that could be accomplished, is beyond my present level of expertise.
    As for using this approach with other browsers, I'm not sure that all browsers provide automation hooks, so embedding the default browser may not be so easy. Finally, trends toward tightening browser security may lead Microsoft to prevent or restrict automating even Internet Explorer.
    This is all I can think of -- Francois & Frank probably have more insightful suggestions.
    Hope this helps,
    Eric Adamson
    Lansing, Michigan

  • What is an enterprise java bean

    Hi,
    What is an enterprise java bean. How is it different from normal java means.
    Thanks a lot,
    Chamal.

    Well an EJB is a object components that lives in the server's container's guts, there are 3 kinds of EJB:
    * Session Beans: performs bussines operations
    * Entity Beans: represents a table from a relational database
    * Message Driven Beans: receives and controlls messages.
    more information about it can be found at: http://java.sun.com/products/ejb/reference/docs/index.html

  • Confused what exactly Java Servlets are?

    Hi,
    I(JSP Biginner) have gone through some tutorials about JSP, Servlet and Java bean.
    I'm really confused by the term SERVLET.
    There are a lot of the definitions:
    1.) Is a Java Class that provides special Server Side Specification.
    2.) A servlet is a dynamically loaded module that services requests from a Web server.
    From above mentioned definition, my understanding is, SerVlet is like an engine which is provided server service. Is the SERVLET that I mentioned same as the JSP Servlet Engine which parse the JSP file, generate and compile the servlet source code and then send it to the browser?????
    3.)What about the SERVLET that created by developer and use in the JSP page? what are the differents between the servlet 1,2 and 3.
    Please advice!

    thanks so much...
    guess I have better understand of what java servlet is when I read the article from
    http://www.novocode.com/doc/servlet-essentials/
    from my understanding:
    1.) we said that SerVlet Provides Request and Response services is because the purpose of we creating our servlet is used to Read (Request) the data from Client and Send back (Response) the data to the Client. Of course all this can be done by code in the JSP page, but because of SerVlet technology, instead of we write the long code in the JSP page, we can modularise our code by creating servlet, why?? as servlets are web components, they can be reused easily. Moreover, java servlet is platform independent. After that at our JSP page, we just call the servlet we have created.
    2.)As we can see from all the example, a SerVlet sure has
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    Are all of them only available when we installed our Web Server (i.e tomcat)???
    3.)Can I say that we create servlets by Inherit all the routines and structure in those classes (q.2), as well as use their Built-In functions to create our servlets???
    4.) Can I say that we create servlet by create an instance of a BIG SERVLET which served as a base (Which has all the classes we needes for creating our own servlets)
    I don't know how much you can understand what I'm writting. Anyway, hope u can help.
    Thanks so much.

  • What is the difference between java direct or java bean in JSP?

    What is the difference if I use java code directly in JSP or use java bean in JSP?
    Which class to use for receiving the passed parameter from html or java script? Any difference for java code and java bean in the way receiving the passed data?
    How can I pass string from jsp to html or java script?

    it's generally accepted as better design to separate presentation from logic. meaning, the java code in the jsp should be used to support displaying data, as oppsoed to implementing the application - like database access, etc.
    when the logic is separated from the presentation, it allows you to reuse logic components within several jsp pages.
    if you decide to change the presentation layer in the future (to support wap, for example) you don't need to rewrite your entire application, since the "guts" of the application is outside of the jsps.
    it is also a good idea to separate your business logic from your data layer. adding a "buffer zone" between these layers helps in the same manner as in separating presentation from logic. if you're using flat files for storage now, upgrading to a database wouldn't require rewriting all your business logic, just the methods which write out the data to a file, for example.
    once you feel comfortable with separating the various layers, check out the struts framework at http://jakarta.apache.org/
    to answer your second question, to get parameters passed in from HTML forms, use ServletRequet's getParameter() method.
    in tomcat:
    <% String lastName = request.getParameter( "lastname" ); %>
    to answer your third question: when displaying the HTML from withing a jsp, print out the string to a javascript variable or a hidden form element:
    <% String firstName = "mike"; %>
    <input type="hidden" name="firstname" value="<%= firstName %>">
    <script language="javascript1.2">
    var firstName = "<%= firstName %>";
    </script>
    this jsp results in the following html:
    <input type="hidden" name="firstname" value="mike">
    <script language="javascript1.2">
    var firstName = "mike";
    </script>

Maybe you are looking for

  • Importing IPTC keywords into iPhoto

    I have >10,000 photos from my research project with imbedded metadata including four keywords. These are in the IPTC field separated by commas. keyword_1, keyword_2, keyword_3, keyword_4 When I import these into iPhoto I get a single keyword keyword_

  • Office 2010 unstable

    L.S.  I've recently acquired an Acer laptop running Windows 8.1. I installed Office 2010 (as I already had a license for it). At first. Word, PowerPoint and Excel would continuously lock up after only the slightest of work performed. I killed an Acer

  • How to use Ctrl+X

    Hello friends I want to trap Ctrl+x to achieve some short key, I have written this code but it is not working. In this code if we change isControlDown() to isAltDown() or isShiftDown() then it is working for Alt and Shift key but not for Control Key.

  • Pb with getting Dreamweaver evaluation version

    Hello, I downloaded an evaluation version of Adobe Creative Cloud (in 2014, October the 8th), because I wanted to evaluate Dreamweaver before buying it. But in the Apps window, I could never see anything (except the hourglass icon...). I have to say

  • Converting to PAL from 1080p

    I'm about to start on a short, somewhat animated sequence in HD. The final output will be NTSC dvd, PAL dvd, and HD 1080 24p or 30p for download. I don't care what frame rate the original sequence is at whether it's 24p or 30p, I just want it to be i