× Please, log in to give us a feedback. Click here to login

You must be logged to download. Click here to login


MrBool is totally free and you can help us to help the Developers Community around the world

Yes, I'd like to help the MrBool and the Developers Community before download

No, I'd like to download without make the donation


MrBool is totally free and you can help us to help the Developers Community around the world

Yes, I'd like to help the MrBool and the Developers Community before download

No, I'd like to download without make the donation

JSP Servlet: Implementing multi-client support

In this article we will discuss about the multi-client support feature in JSP (Java Server Pages) and Servlet.

The term multi-client means that there are different types of clients visiting the Web site. Most commonly, designers only think of a web site as Hyper Text Markup Language and the client is using some software that can be viewed through Hyper Text Markup Language. Though, this practice does not always make sense as the Hyper Text Markup Language is not the individual technology that is used on the Web, and even if it were, there are various difficulties to be addressed.

At the starting point, we have to consider the fact that there are different versions of Hyper Text Markup Language. Now the Coding for full backwards-compatibility with the HTML 1.0 is not very accommodating, since it excludes taking advantage of the current Hyper Text Markup Language features. The only well-thought process is to endeavor and maintain all of the different versions of Hyper Text Markup Language or to selectively sustenance a version of Hypertext Markup Language that is a middle-of-the-road approach.

Now, we also consider other technologies in addition to Hyper Text Markup Language. There are a lot of technologies exist to work with Hypertext Markup Language, technologies such as Cascading Style Sheets, ECMAScript, and the Document Object Model (DOM). And many technologies exist that can also replace Hyper Text Markup Language such as XHTML, XML (Extensible Markup Language), MS Word, and Adobe’s Portable Document Format (PDF). Choosing only to support the basic Hyper Text Markup Language greatly limits the type of content that Java Server Pages can deliver.

Implementing Multi-Client Support

There are a few techniques commonly used to provide multi-client support. Now a lot of methodologies also work, nonetheless it is desirable to have a multi-client design that generally supported by the following way:





Eliminates redundancy

This Eliminates redundancy. Mutually the static text and non-formatting-related code that fall into this category. Now a respectable explanation that should not necessitate numerous copies of the same code. If the multiple copies of text or code be present, maintenance will become more difficult because a change of one copy requires changing all copies in the project. This is the primary motivation why a Model 2 designs provides a good place to implement the multi-client support architecture. Here we Should use Java Server Page that is embedded with our business logic, like a user login check process, there every Java Server Page presentation need a code. The simple change to one of the pages would require a change to all of the pages. A good multi-client design disrespects all types of redundancy (same types of the record entry more than one).


Easy to use

A very good multi-client design should be easy to use and extend. The Java Server Page is a powerful tool because it is very flexible. Here the markup language associated with a Java Server Page is easier to understand than Java code.


Cleanly extensible

Now the clean and extensible motivation for the multi-client design is used for different types of content formatting. Basically a good multi-client design provides a general framework for implementing any types of formatting that generally require now and in the future scope. The formats that should also be cleanly separated from each other. Now manipulating only one format that should not affect other prospect of the system.

Table 1: Showing Multi-client design features

The term template refers to creating a Java Server Page that is formatting the template as well as content is pushed through the system. Creating support for a new format can be accomplished by creating a new template. In general practice this approach requires building a set of Java Server Page for each format required. The important point is to remember that in example there are multiple possible Java Server Page endpoints to a request. Different endpoints generate equivalent pages nevertheless in different formats. The number of endpoints is the number of formats desired.

As an alternative of always assuming a single endpoint, the control component that needs to selectively forward to the Java Server Page, responsible for the specific format as per our requirement. The code for selectively forwarding can easily be done by using a fictitious Uniform Resource Locator and some browser (like Google Crome, Internet Explorer11, Mozilla Firefox) client-detection code. As per illustration, a Filter can be used to intercept of all the requests to the Web Application. Basically that requests for the fictitious Uniform Resource Locator ending with .html (extension of HTML files) are forwarded to an HTML-formatting JSP; requests for the fictitious Uniform Resource Locator ending with .xhtml (This actually Extensible Hyper Text Markup Language. We also define that XHTML is almost undistinguishable to Hyper Text Markup Language 4.0. XHTML is a cleaner version of Hyper Text Markup Language) and promoted to an XHTML-formatting Java Server Page.

We consider a web site for the different formatting and a filtering to encapsulate (hidden the logic which outside world cannot access directly) all business logic. A little code is presented here which will give us a clear idea about the filter process in Multi-client architecture model.

Filter_jsp.java //name of the java program

Listing 1: Sample showing filter

  Package com.bceibook; //Package name
  import java.io.*; //This is input output package
  import java.util.*;
  import javax.servlet.*; //This is servlet package
  import javax.servlet.http.*;
  public class filter_jsp implements Filter 
  FilterConfig fc1 = null;
  public void doFilter(ServletRequest req,ServletResponse res,
  FilterChain chain) throws IOException, ServletException
  HttpServletRequest request = (HttpServletRequest) req;
  String u = request.getRequestURI();
  String client = "Hypertext Markup Languages";
  if (u.endsWith("xhtml"))
  client = "Welcome to mrbool learning ";
  // this part is the business logic...
  HashMap udata = new HashMap();
  udata.put("name", "BCEI..");
  request.setAttribute("udata", udata);
  ServletContext s = fc1.getServletContext();
  forward(request, res);
  public void init(FilterConfig filterConfig) 
  fc1 = filterConfig;
  //This function is written for destroying the filter that generally set with null data
  public void destroy()
  fc1 = null;
  } // End of the program.

Now, we have to save this program with BCEITemplateFilter.java in the /WEB-INF/classes/com/bceibook directory of the bceibook the Web Application. After that we must save the files as BCEIexampleHTML.jsp and BCEIexampleXHTML.jsp, respectively, in the /mc directory of the bceibook of that Web Application. The Filter is used to capture an application and directs it to either the Hyper Text Markup Language or EXtensible Hyper Text Markup Language template depending on the ending of the Uniform Resource Locator.

  String uri = request.getRequestURI();
  String client = "Hyper Text Markup Language..";
  if (uri.endsWith("xhtml")) 
  client = "EXtensible Hyper Text Markup Language..";

Generally the client variable is set to Hyper Text Markup Language, meaning the Hyper Text Markup Language version of the page will be shown here. Here the Uniform Resource Locator end with ".xhtml", then the EXtensible Hyper Text Markup Language version of the page is exposed. Usually the doFilter() function is directly used with the Java Server Pages. Here we are discussing another page format.

  ServletContext s = fc1.getServletContext();
  forward(request, res);

The accurate Java Server Pages that is used for the beginning of the page. As well as the file "BCEIexample" that is affixing either Hyper Text Markup Language or EXtensible Hyper Text Markup Language, and after that it goes to finally ".jsp" file.

Try out the code example by deploying BCEITemplateFilter.java to filter all requests to the /mc directory.

Listing 2: Example showing filter format


After writing the code it is very much important to deploy the Filter, reload the bceibook in the Web Application and browse to The output of the given page is shown in the Hyper Text Markup Language version, BCEIexampleHTML.jsp.

After that we are now discussing example 3 which is helpful for setting up the situation.

Listing 3: Response from BCEIexampleHTML.jsp

  <title>Program of Client Server Architecture Model</title>
  <body bgcolor=”lightyellow”>
  <img src="cei.bmp">
  <h1>Welcome to Computer Educational Institution…</h1>

The response is the Hypertext Markup Language version of the page. After that we go to browsing option and try to open In general this response is returned back in the Extensible Hypertext Markup Language page.

Listing 4: Here the Response Generated by BCEIexampleXHTML.jsp

  <title>It is support with the Multi-Client Support Process.</title>
  <body bgcolor=”lightyellow”>
  <img src="cei.bmp"/>
  <h1> Welcome to Computer Educational Institution…</h1>

This code is resumed as an Extensible Hypertext Markup Language process. The point should be remembered that browser (Internet surfing software) interpretations of the results are not used because they basically more and more identical. Now in this article we state simple examples that deliver us actual protocol for creating the template system that can be produced for a Web site. The actual formats are detected by the Uniform Resource Locator extension and one main Filter interrupts to all requests and directs them to the appropriate reserve system. The former illustration can be extended to create a Filter which distinguishes Hypertext markup Language and Extensible Hypertext markup Language support. In that request header the client sends the user representative field. As well as this header encompasses the information about the software and a client who is using to visit a site. The user-agent header can be extracted to administrate if the client is using Mozilla, Internet Explorer 11, Netscape Navigator, or any other popular Web browser.

Benefits and Drawbacks of Templates

Here we will discuss some commercial benefit and drawback of the Template model

  1. The benefit of the templates is easy to and intuitive to generate, especially for markup language formats.
  2. Java Server Pages that already excels at producing these formats and most writers know how to use Java Server Pages to make them in our working field.
  3. The actual drawback of a template is that each design requires a new Java Server Page.
  4. The Java Server Page muddle a Web Application, nevertheless more importantly multiple copies tempt a developer to put redundant content in the templates.
  5. The rest of the content on the page is copied directly in the system, leaving two copies of the same information process.
  6. The Hypertext Markup Language template can be changedThe same changes would need to be pragmatic to the Extensible Hypertext Markup Language template format also.
  7. Solving the problem of the terminated content on the templates require some work or development.
  8. The clarification is to treat all text as if it is dynamic and pull the content from one central location.
  9. The Static content is then combined into one place and more easily maintained.
  10. This template page end up by looking the following example from the internationalization process.

Listing 5: Listing Consolidated Content

  <body bgcolor=”lightyellow”>
  <img src="cei.bmp">

The following diagram is showing multi client architecture.

Figure 1: Multi-Client Architecture


Basically the transformation is very much multifaceted nevertheless supplementary to full-bodied multi-client explanation associated to the templates process. The basic transformation in between a template and a transformation system is that the transformation generally uses an interface other than pseudo-format, for the efficiently nonrepresentational of the final format. Because at that moment a client sends requests to a particular format, the pseudo-format is transformed into the concluding result or we may call final result. Now here we are discussing some common example.

Listing 6: Multi-Client code for show “Hello BCEI” Page

  <p style="font-size:24pt; color:green;">HelloBCEI….</p>

Figure 2: Web Application

Implementing Transformations

There are some existing approaches of implementing the transformations with Servlets and Java Server Pages. Basically some common approaches are to be used for Java Server Pages custom tags to abstract all types of formatting or to use Java Server Pages to produce a standard format and have a Filter transform the result. Now in this article we will discuss about framework and some techniques.






FOP stands for Formatting Objects Processor; it is a framework that designed to take Extensible Style Sheet for formatting the Objects. The framework primarily supports Portable Document Format; nevertheless it has partial maintenance for many other formats as per our requirement.



Cocoon is a framework built by the Apache Jakarta community and is designed to pipeline Extensible Markup The framework allows Java Server Pages as a starting point, but is really more of a Java Server Pages alternative. The Cocoon does is by taking a starting Extensible Markup Language document and relate a number of the Extensible Style sheet transformations to it. Cocoon also supports FOP for transformations on XSL-FO.


Multi-Client Tags

The Multi-Client Tags framework is an endeavor to manufacture the simplest possible multi-client interface or architecture. The project is very simple to learn (literally takes five minutes) and also generates Hypertext Markup Language, Extensible Hyper Text Markup Language, Portable Document Format, and printer-friendly formats.

Table 2: Showing transformation techniques


Client Server architecture is very important architecture in our software development field but this system communication is not an easy process. The Multi-client system is designed to enable a Servlet and Java Server Pages designer or developer to accurately design dynamic Web Applications. Nevertheless, when we design around only Hyper Text Markup Language that is fundamentally limits what a Web Application can do. Now, the concept of abstracting formatting logic similar to abstracting of the content is also very effective. So the multi client support can be developed by following the approaches discussed above.

Website: www.techalpine.com Have 16 years of experience as a technical architect and software consultant in enterprise application and product development. Have interest in new technology and innovation area along with technical...

What did you think of this post?
To have full access to this post (or download the associated files) you must have MrBool Credits.

  See the prices for this post in Mr.Bool Credits System below:

Individually – in this case the price for this post is US$ 0,00 (Buy it now)
in this case you will buy only this video by paying the full price with no discount.

Package of 10 credits - in this case the price for this post is US$ 0,00
This subscription is ideal if you want to download few videos. In this plan you will receive a discount of 50% in each video. Subscribe for this package!

Package of 50 credits – in this case the price for this post is US$ 0,00
This subscription is ideal if you want to download several videos. In this plan you will receive a discount of 83% in each video. Subscribe for this package!

> More info about MrBool Credits
You must be logged to download.

Click here to login