Java Reference
In-Depth Information
In the Servlet Parameters window, servlet parameters may be specified. Click on
Finish . We shall be packaging the servlet class in a WAR file along with the JSP UIs
for the Ajax. In the web.xml, the EJB3ClientServlet and the url pattern to invoke
the servlet get specified. The web.xml is listed below:
<?xml version = '1.0' encoding = 'windows-1252'?>
<web-app xmlns:xsi=""
xsi:schemaLocation=" http://java."
version="2.5" xmlns="">
The Servlet class
The Ajax request is sent from the input form to the doGet() method of the servlet.
In the doGet() method, create an InitialContext object:
InitialContext context = new InitialContext();
Lookup the remote business interface using the remote JNDI name:
SessionEJBFaƧade beanRemote = (SessionEJBFaƧade) context.
Retrieve the catalog id input field value and invoke the validate() method of the
session bean:
String catalogId =request.getParameter("catalogId");
Catalog catalog = beanRemote.validate(catalogId);
The servlet sends a response to the browser as an XML string; therefore, set the
content type of the HttpServletResponse to text/xml , and the cache-control
header to no-cache :
response.setHeader("Cache-Control", "no-cache");
Search WWH ::

Custom Search