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>

Similar Messages

  • What's the difference between include directive & include action tag?

    I no that the directive is used for including static content,
    while the action is also used for dynamic content.
    So the first one will include the content into the JSP only at compilation time. The second one will include the content every time you access the JSP.
    *<html>*
    *<body>*
    *<h1> Include Action test PAge</h1>*
    *<h2> Using the include directive</h2>*
    *<%@ include file="included2.html"%>*
    *<%@ include file="included2.jsp"%>*
    *<h2> Using the include action</h2>*
    *<jsp:include page="included2.html" flush="true"/>*
    *<jsp:include page="included2.jsp" flush="true"/>*
    *</body>*
    *</html>*    I tried withis code. But its giving the same result.I didn't modified the source. I modified in the included file.As I request for the JSP page I got the same result for both.
    so i just want to know that is thier any way or example by which i can see the difference between these two clearly..
    please help me out.
    thnx.

    As our almighty Google says: @include is compiletime and jsp:include is runtime.
    Install Google at your machine. It's really great. It has answers on almost all questions.

  • What's the difference between Netscape SDK for Java & JNDI?

    I know I can use either JNDI or Netscape SDK to access iDS. So whats their differences basically?
    Why would I need JNDI/Netscape SDK if I can just use either of them to access iDS?
    Thanks!

    Netscape SDK for JAVA developed only for iplanet Directory Server but JNDI for any directory server.
    JNDI has classes provided by Sun that will help your application interact with an LDAP server.JNDI applications work similarly to JDBC applications - write applications once and be free to use "drivers" from different vendors. Sun provides the "driver" that will help interact with the LDAP server. Sun also provides "drivers" for other naming services (like CORBA, Netscape).
    The Java Naming and Directory Interface (JNDI) allows Java applications to use a single set of methods to access multiple naming and directory services such as LDAP and NIS.
    JNDI is a Java API that provides a common way for programmers to access a variety of naming and directory services. The API consists of several packages:
    javax.naming for naming operations (access entries)
    javax.naming.directory for directory operations (access attributes)
    javax.naming.event for requesting event notification
    javax.naming.ldap for LDAP-specific features.
    JNDI operates through a layer of software called a Service Provider. The Service Provider implements the JNDI operations in terms of a particular underlying protocol.
    JNDI's Service Provider Interface (SPI) allows you to select Service Providers at runtime. In many cases you can use the same JNDI methods regardless of whether the Service Provider is talking to an LDAP server or using another protocol such as NIS. In order to access all of the functionality of the LDAP protocol, however, you will have to use methods outside of this abstraction.

  • What is the difference between these setter methods

    What is the difference between these two setter methods??
    <jsp:useBean id="checking" scope="session" class="bank.Checking" />
    <jsp:setProperty name="checking" property="balance" value="0.0" /> and
    <jsp:useBean id="checking" scope="session" class="bank.Checking" >
    <jsp:setProperty name="checking" property="balance" value="0.0" />
    </jsp:useBean>

    Homework question?
    The answer is on this page (Step 5)
    http://java.sun.com/products/jsp/syntax/1.2/syntaxref1217.html#8865

  • What's the difference between Java SDK and the Enterprise Edition?

    What's the difference between Java SDK and the Enterprise Edition? Are they both free?

    both r free but they are used in diffrent applications. sdk are used for simple apps that run on your computer while j2e (enterprise edition) are ment for large distributed computer systems that include servers and such. if you don't know the diffrence you probably wont need the the j2e, only the sdk.

  • What's the difference between "overloading" and "overriding" in Java

    What's the difference between "overloading" and "overriding" in Java

    hashdata wrote:
    What is the real-time usage of these concepts...?Overriding is used when two classes react differently to the same method call. A good example is toString(). For Object it just returns the class name and the identityHashCode, for String it returns the String itself and for a List it (usually) returns a String representation of the content of the list.
    Overloading is used when similar functionality is provided for different arguments. A good example is [Arrays.sort()|http://java.sun.com/javase/6/docs/api/java/util/Arrays.html#sort(byte%5B%5D)]: all the sort() methods do the same thing (they sort arrays), but one sorts byte-arrays, another one sorts int-arrays, yet another one sorts Object-arrays.
    By the way, you almost certainly mean "real-world" usage. "real-time" (and thus "real-time usage) means something entirely unrelated to your question.

  • Do I need Java 8 or should i disable it? What happens if i disable it? And what is the difference between Java and Java Runtime?

    Do I need Java 8 or should I disable it? What happens if i disable it? And what is the difference between Java and Java Runtime?

    There's no difference. They're both runtime plug-ins (they run when an app calls for Java functions).
    You only need Java if you either have Java apps on your Mac that won't run without having it installed, or you use trusted web sites that require Java to function (getting fewer and far between). Otherwise, you have no need for it at all.

  • What are the differences between Sun Certified Programmer for Java 2 Platfo

    Hi
    What are the differences between Sun Certified Web Component Developer for the Java 2 Platform, Enterprise Edition 1.4 (CX-310-081) and 5 (CX-310-083) exams?
    What has been removed from the new web component developer 5 exam?
    What has been added to the new web component developer 5 exam?
    Thanks in Advance

    what (apart from laziness) is preventing you from looking up the information for yourself?

  • Java-options, What is the difference between the parameters xms and ms

    Hi,
    I have a problem with deploy bpel process , I get an error "java.lang.OutOfMemoryError: PermGen Space" several sources of information tells me that I have to change some parameters in the file "<ORACLE_HOME> / opmn / conf / opmn.xml" but I doubt some of the parameters, what is the difference between Xms and ms?
    And what is the value of the parameter MaxPermSize, which I must also change.
    Thanks
    Gustavo

    Did you ever find out what the difference between the two parameters were!? I have the same questions. Default for opmn.xml = "-server -XX:MaxPermSize=128M -ms512M -mx1024M ...." In attempting to maximize performance and accessible memory, Oracle docs identify adding/modifying "-server -Xmn1228m -XX:+AggressiveHeap -Xms2048m -Xmx2048m -XX:MaxPermSize=128M -ms2048M -mx2048M...." But I question if Xms and ms are really the same parameter or not?
    Thanks in advance...
    Steve

  • What is the difference between jsp :include and server side include

    what is the difference between jsp :include and server side include(request dispatcher include method)????
    i understand that both request dispatcher include method and jsp:include take dynamic data,so when would one use request dispatcher include and when jsp:include.
    Is the usage interchangeable?i believe jsp include is used only for jsp/html but include directive can be used to include servlets ,jsp and html....correct me if i m wrong and
    do suggest if u hav ny other diff in this context...

    The difference really is: in what format do you want your inclusions? If your environment has many Java developers and only a few designers that focus mainly on, say, Flash, that might push you more towards the server-side include() directive. Or, if you have a large set of pages that receive dynamic content that is displayed in a consistent fashion (such as a workflow header area on a page).
    If, on the other hand, you have more web designers, there may be a greater desire to deal in markup rather than Java code. Java developers themselves might prefer to view markup (JSP) that more resembles the eventual output than something occuring in Java code.
    Finally, there are considerations of tiering. While it is totally possible to (and I have previously) implement 'view classes' that render markup or generate layout templates, JSP's offer, IMO, a subtle, psychological advantage. By forcing a developer to work in a different format, markup versus Java source, the separation on view from controller and model becomes a bit easier. It is still possible to make mistakes, but if a developer at some point notices, "Wait, I'm in a JSP, should I be importing a java.sql class?", then the choice to use JSP includes has paid off in spades.
    - Saish

  • What is the difference between the normal function module and bapi function

    hi,
    what is the difference between the normal function module and bapi function module.

    Hi
    BAPI stands for Business API(Application Program Interface).
    A BAPI is remotely enabled function module ie it can be invoked from remote programs like standalone JAVA programs, web interface etc..
    You can make your function module remotely enabled in attributes of Function module but
    A BAPI are standard SAP function modules provided by SAP for remote access. Also they are part of Businees Objest Repository(BOR).
    BAPI are RFC enabled function modules. the difference between RFc and BAPI are business objects. You create business objects and those are then registered in your BOR (Business Object Repository) which can be accessed outside the SAP system by using some other applications (Non-SAP) such as VB or JAVA. in this case u only specify the business object and its method from external system in BAPI there is no direct system call. while RFC are direct system call Some BAPIs provide basic functions and can be used for most SAP business object types. These BAPIs should be implemented the same for all business object types. Standardized BAPIs are easier to use and prevent users having to deal with a number of different BAPIs. Whenever possible, a standardized BAPI must be used in preference to an individual BAPI.
    Regards
    Anji

  • What is the difference between object, instance, referance?

    What is the difference between object, instance, referance of a class? write some code for that, that will be easy to understand for me.
    Thank you.

    petes1234 wrote:
    paul.miner wrote:
    You'll get a more useful reply if you ask a better question. As it is, your question is overly broad and vague. I beg to differ. I found it direct and to the point: "Please do my homework".I too found it direct but not like that.
    I translated the request as "I am just starting to learn Java and don't understand any of the basic concepts. Could I please have some code that could maybe explain this concepts more clearly so that I can get a practical sense of them?"
    And the answer is... the tutorial.
    I agree the second sentence reads to you and I (and probably others) as demanding, but I think it's just an ESL issue. He/she at least said thanks.

  • What is the difference between mp4 for iphone and mp4 for ipod ?

    I have converted some videos to mp4 and there is a choice to convert to iphone or ipod.
    But what is the difference between them ?
    It cant just be something simple like screen size / resolution.
    Because I have some mp4 videos that will sync with itunes onto my iphone, but not onto my ipod 5th gen.
    Do you have to have both types of mp4 videos, one for the iphone and one for the ipod ?
    If so then thats a right pain the in arse.
    I would have thought mp4 is mp4 and would work on both the iphone and the ipod ?

    There is no difference because as you said Java is platform independenec. However, the installer is platform-dependent so we needed to package the Beans differently.
    All the java classes and libraries are identical

  • What is the difference between SAP NW PI7.1 and PI7.1 EHP1

    We have a customer using SAP PI7.1 EHP1. The application to be deployed
    isdeveloped on SAP Netweaver PI 7.1 SP06.
    We need to know if application developed and transported from PI7.1 is
    compatible with EHP1?
    Below are the Components used by the application .
    1) SSL communication using SOAP adapter
    2) Java mapping , Graphical mapping , XSLT mapping
    3) Customised EJB modules
    4) Adapter framework
    5) ALE layer for IDoc communication from ERP to PI
    6) RFC lookups to PI system and ERP system.
    Questions
    1)Will PI EHP1 be able to communicate with PI7.1 using SOAP adapter ?
    2) What is the difference between SAP NW PI7.1 and PI7.1 EHP1 ?
    Regards,
    Sneha

    Hi,
    EHP Pi7.1 new
    IPv6 Support in SAP Systems (new)
    Async/Sync and Sync/Async Bridge in the JMS Adapter (New)
    High Availability (New)   Locate the document in its SAP Library structure
    Use
    A new concept is available for setting up a high availability environment for SAP NetWeaver Process Integration (PI). To do this, you need SAP Web Dispatcher for load balancing, and you must reconfigure your HTTP, RFC, and RMI connections so that they can be used for load balancing. You must also make various configuration steps in other components of your PI environment.
    [Level 4: Document: XML to Text Conversion Module (New)] XML to Text Conversion Module (New)
    Message Packaging (New)
    Monitoring Milestones (New)   Locate the document in its SAP Library structure
    Use
    You can use the new scenario variant Monitoring Milestones of the Business Process Management scenario to define a monitoring process that can monitor events from different applications. A monitoring process can subscribe to events from SAP or non-SAP systems.
    check  given Link
    http://help.sap.com/saphelp_nwpi711/helpdata/en/61/8c3842bb58f83ae10000000a1550b0/frameset.htm
    Regards,
    Amit

  • What is the difference between ojvm and client versions?

    Changing the java vm from client to ojvm result in the following error:
    Errormessage:
    java.lang.UnsatisfiedLinkError: no UniqueC in java.library.path
    Project Settings -&gt; Configurations -&gt; Development -&gt; Runner -&gt; Virtual Machine -&gt; ojvm FAILS
    Project Settings -&gt; Configurations -&gt; Development -&gt; Runner -&gt; Virtual Machine -&gt; ojvm      RUNS OK.
    Project Settings -&gt; Configurations -&gt; Development -&gt;Paths -&gt;Additional Classpath:
    C:\jars\xerces.jar;C:\jars\UniqueC.dll;C:\jars\log4j-1.2.8.jar
    What is the difference between ojvm and client versions? How can I make ojvm to find UniqueC.dll?
    Various version info:
    Output from program:
    java version:1.4.2_01
    java home:C:\programfiler\JAVA\2sdk1.4.2_01\jre
    java vm version:9.0.3.738 cdov
    Taken from JDeveloper Help About:
    Oracle IDE     9.0.3.10.35
    UML Modelers Version     9.0.3.9.4
    Business Components Version     9.0.3.10.7
    java.version     1.3.1_02
    java.vm.name     OJVM Client VM
    java.vm.version     9.0.3.738 o

    However, Adobe offers extra paid services to create PDF or to export PDF to other formats. You are not required to buy them, however.

  • What is the difference between iterator.remove() ArrayList.remove()?

    Following code uses iterator.remove() ArrayList.remove().
    public class CollectionRemove
        private static void checkIteratorRemove()
             List<String> list = new ArrayList<String>();     
              list.add("1");
              list.add("2");
              list.add("3");     
             System.out.println("in checkWithIterator*************");
            Iterator<String> iter = list.iterator();
            while (iter.hasNext()) {
                String str = iter.next();           
                if (str.equals("2")) {
                    iter.remove();
                System.out.println("list Size: " + list.size() + " Element: " +  str);
        private static void checkListRemove()
             List<String> list = new ArrayList<String>();     
              list.add("1");
              list.add("2");
              list.add("3");     
            System.out.println("in ncheckWithForLoop*************");
            Iterator<String> iter = list.iterator();
            while (iter.hasNext()) 
                 String str = (String) iter.next();    
                if (str.equals("2")) {
                    list.remove(str);
                System.out.println("list Size: " + list.size() + " Element: " +  str);
        public static void main(String args[])
             checkIteratorRemove();
             checkListRemove();
    output is :
    in checkWithIterator*************
    list Size: 3 Element: 1
    list Size: 2 Element: 2
    list Size: 2 Element: 3
    in ncheckWithForLoop*************
    list Size: 3 Element: 1
    list Size: 2 Element: 2Why is this difference ? what is the difference between iterator.remove() ArrayList.remove()?

    In the case of Fail-fast iterator, if a thread modifies a collection directly while iterating over it, the iterator will thow ConcurrentModificationException . Say,
    for (Iterator it = collection.iterator(); it.hasNext()) {
        Object object = it.next();
        if (isConditionTrue) {
            // collection.remove(object);  can throw ConcurrentModificationException
            it.remove(object);
    }As per specs,
    Note that this exception does not always indicate that an object has been concurrently modified by a different thread. If a single thread issues a sequence of method invocations that violates the contract of an object, the object may throw this exception. For example, if a thread modifies a collection directly while it is iterating over the collection with a fail-fast iterator, the iterator will thow this exception.

Maybe you are looking for