Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

could anyone explain

bengesbenges Member Posts: 331
i have some question in Java Server Page, Sevlet, Java Bean and also Java Script, below are the doubt i wish to clearify:

1.) is Java Server page a Sevlet?
2.) what is the different between the Java Server page and Bean and Java Script?
3.) is there any possible to send value through parameter from and to each of the file format above?

the question may bit easy and more, but i do wish guys you all can help me understand more or is there a website to this explaination? thank you very much

Comments

  • BreadfanBreadfan Member Posts: 22

    1. The JSP is turned into a servlet; all the non-scriptlet code you have written i.e. everything outside the <% %> is passed through to the servlt's Writer.

    if you have this content in your JSP:


    non-scriptlet part of a JSP page
    <%
    out.println("this is part of the scriptlet");
    %>



    it would look something like this in the .java file of the generated servlet:

    out.println("");
    out.println("non-scriptlet part of a JSP page");
    out.println("");
    out.println("");

    and some other code...

    everything in the <%! %> (declaration maybe) part of the JSP page is turned into member variables of the Servlet.

    2. JSP is a server-side technology that makes it possible to use the Java language in web pages; server-side means that the code in the JSPs as the code in the servlets is executed on the server machine. You cannot register events like onMouseOver, onClick and so on in JSP; you can only access submitted data and the parameters passed in a URL string "http://mypage.something.com/index.jsp?id=002&time=168485".

    JavaScript is a client-side language - it can register and handle those events onMouseOver, onClick, etc.

    Both JSP and JavaScript have access to various predefined objects, but that's too long.

    I don't know much about JavaBeans, the only thing I'm sure about is that JavaBeans classes must have an empty constructor:

    public MyBean(){}

    and for every member variable there must be a setter and a getter method:

    private int number=15;

    public void setNumber(int num){this.number=num;}
    public int getNumber(){return this.number;}

    3. it is possible to pass params from JavaScript to JSP via an URL or query string
    this.location.href=
    "http://mypage.something.com/index.jsp?id=002&javaScriptVar="+jsVar;

    you can pass a JSP parameter by doing this:

    <%
    out.println("<script type="text/javascript">");
    out.println("var myVar="+request.getParameter("id"));
    out.println("alert('JSP variable is passed to a JavaScript variable: '+myVar);");
    out.println("");
    %>




    : i have some question in Java Server Page, Sevlet, Java Bean and also Java Script, below are the doubt i wish to clearify:
    :
    : 1.) is Java Server page a Sevlet?
    : 2.) what is the different between the Java Server page and Bean and Java Script?
    : 3.) is there any possible to send value through parameter from and to each of the file format above?
    :
    : the question may bit easy and more, but i do wish guys you all can help me understand more or is there a website to this explaination? thank you very much
    :

Sign In or Register to comment.