The HTMLServlet class represents a server-side include. The servlet object specifies the name of the servlet and, optionally, its location. You may also choose to use the default location on the local system.
The HTMLServlet class works with the HTMLParameter class, which specifies the parameters available to the servlet.
Methods for the HTMLServlet class include:
The following example an HTMLServlet tag:
// Create an HTMLServlet. HTMLServlet servlet = new HTMLServlet("myServlet", "http://server:port/dir"); // Create a parameter, then add it to the servlet. HTMLParameter param = new HTMLParameter("parm1", "value1"); servlet.addParameter(param); // Create and add second parameter HTMLParameter param2 = servlet.add("parm2", "value2"); // Create the alternate text if the Web server does not support the servlet tag. servlet.setText("The Web server providing this page does not support the SERVLET tag."); System.out.println(servlet);
The previous example produces the following tags:
<servlet name="myServlet" codebase="http://server:port/dir"> <param name="parm1" value="value1"> <param name="parm2" value="value2"> The Web server providing this page does not support the SERVLET tag. </servlet>