Java JSP / JSF

JSP Application Architectures

javaIn the software world ; business application developers and web page designers are different people. While appliction developers develop projects , web  page designers design the same projects. However in real life, especially software everything won’t be good and roles are mixed . Because of that we prefer two architectures in the software worlds.

In the first architecture model, the application logic is implemented with Java Class (jave beans ) and you can use in JSP pages.  This model is good and acceptable for applications but there are a lot of codes in JSP pages,  a few months later it can cause problems for web page designers.

The second architecture model:  This architecture model is better than the first one and it is suitable for large applications.

This model a seperate application logic and web page presentation.  It is called the MVC Model (Model View Controller).

In this model, a servlet proceses the request and handle the application logic then instantiate java beans (java beans mens  java class)

JSP obtains data from beans. When the web server send html pages to the users, the users don’t see Java codes or classes.

The second architecture model is better than the first one and more suitable for developers and page designers.

Java JSP / JSF

Browser Model in JSP

javaThe request contains information about browser.  When we use request.getHeader in codes, we will get browser information .

The following codes show us some information ;


Mozilla/5.0 (Windows; U; Windows NT 6.1; tr; rv: Gecko/20110303 Firefox/3.6.15.

The browser type is Mozilla , and the operation system is Windows such as.

We want to get a browser model so that we search Firefox or MSIE in that text.

If we find Firefox in that text, our browser model is Mozilla or if we find MSIE , our browser model is Microsoft İnternet Explorer.

On the other hand;  if we don’t find Firefox or MSIE , we use another browser to connect to the internet.

We use the following codes to find our browser model.


String userAgent = request.getHeader(“user-agent”);

String browser = “Bilinmiyor”;


if (userAgent != null)


if (userAgent.indexOf(“MSIE”)> -1)


browser = “Microsoft Internet Explorer”;


else if (userAgent.indexOf(“Firefox”) > -1)


browser = “Mozilla Firefox”;





Java JSP / JSF

How does the JSP page work?

javaJSP is a dynamic web technology lets you design dynamic content for web pages. Without JSP,  you always have to update the appearance of static HTML pages.

The following steps explain how  a JSP page works :

– You send Http request to the web server.

– The web server is a kind of special server that recognizes http requesties for a JSP page. After that  the web server sends it to the JSP Engine

– The JSP engine converts it into a Java Servlet.

– A part of the web server is called the servlet engine . The JSP engine compiles the servlet into an executable class, after that, sends it to a servlet engine .

– The servlet engine loads the class and executes it.  After that the servlet engine sends the http response to the web server

– The web server forwards the Http response to your browser.

– Our web browser handles http response into the generated Html page.