Servlet tag with SHTML

With the SHTMLServlet, we demonstrate how to make the Web application server dynamically generate part of its HTML file. Using the servlet ...

With the SHTMLServlet, we demonstrate how to make the Web application server dynamically generate part of its HTML file. Using the servlet tag technique, the server converts a section of an HTML file into a dynamic portion each time the document is sent to the client. This dynamic portion invokes an appropriate servlet, and inserts the response of that server in the HTML page that is sent to the Web client. Initialization and other servlet parameters can be passed through the tag syntax, similar to the way an applet’s parameters are set in the HTML. Here, the Web browser is calling the servlet indirectly, through the SHTML page. The Web server is responsible for including the output of the specified servlet in the HTML response.
The HTML syntax is as follows:
<servlet> name="myServlet" code="package.classname" </servlet>
CODE A shows the HTML that we used to call our servlet, and CODE B shows the servlet whose response is dynamically included between the tags. Notice that this servlet only generates a part of the total response back to the Web client.

<H2>Start of SHTML Servlet Example, the following lines are from the servlet:
</H2> <HR>
<SERVLET name="SHTMLServlet”
CODE="itso.servjsp.servletapi.SHTMLServlet"> </SERVLET>
<HR> <H2>ENd of servlet include</H2>

The <SERVLET> tag has been replaced with <jsp:include> in JSP 1.0. See “Calling a servlet from a JSP”  for examples of how to invoke a servlet from a JSP, which is a more modern technique to accomplish the same purpose.

package itso.servjsp.servletapi;
import javax.servlet.*;
import javax.servlet.http.*;
public class SHTMLServlet extends HttpServlet {
public void service(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
PrintWriter out = res.getWriter();
out.println("<HR><H4>Servlet API Example - SHTMLServlet</H4>");
out.println("<H4>Basic included servlet...</H4><HR>");

Best Online Tutorials | Source codes | Programming Languages: Servlet tag with SHTML
Servlet tag with SHTML
Best Online Tutorials | Source codes | Programming Languages
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy Table of Content