Download FAQ History |  | API Search Feedback

> ## Expressions

> A JSP expression is used to insert the value of a scripting language expression, converted into a string, into the data stream returned to the client. When the scripting language is the Java programming language, an expression is transformed into a statement that converts the value of the expression into a `String` object and inserts it into the implicit `out` object.

> The syntax for an expression is as follows:

>     <%= scripting language expression %>

> Note that a semicolon is not allowed within a JSP expression, even if the same expression has a semicolon when you use it within a scriptlet.

> In the Web service version of the `hello2` application, `response.jsp` contains the following scriptlet which creates a JAX-RPC stub, sets the endpoint on the stub, and then invokes the `sayHello` method on the stub, passing the user name retrieved from a request parameter:

>     <%
>         String resp = null;
>         try {
>           Stub stub = (Stub)(new
>             MyHelloService_Impl().getHelloIFPort());
>           stub._setProperty(
>             javax.xml.rpc.Stub.ENDPOINT_ADDRESS_PROPERTY,
>             "http://localhost:1024/hello-jaxrpc/hello");
>           HelloIF hello = (HelloIF)stub;
>           resp =
>             hello.sayHello(request.getParameter("username"));
>         } catch (Exception ex) {
>             resp = ex.toString();
>         }
>     %>

> A scripting expression is then used to insert the value of `resp` into the output stream:

>     <h2><font color="black"><%= resp %>!</font></h2>

Download FAQ History |  | API Search Feedback

All of the material in The Java(TM) Web Services Tutorial is copyright-protected and may not be published in other works without express written permission from Sun Microsystems.