Archive for November, 2007

Thursday, November 29th, 2007

EJB & JSP: Java On The Edge, Unlimited Edition by Lou Marco ISBN: 0764548026 Your Guide to Cutting-Edge J2EE Programming Techniques. Summary The topic of JSP tag extensions is relatively recent, being introduced in JSP release 1.1. The draft specification for JSP release 1.2 discusses additional features of the JSP tag extensions. Searching for JSP tag extensions at http://www.google.com/ returns over 1,300 sites. Those who are “in the know” realize that JSP tag libraries are an essential component of JSP technology.
The European settlement at Melbourne was founded in 1835 by settlers coming from Tasmania (then known as Van Die men’s Land), where they had difficulty finding available land.We provides affordable, discount and cheapest Melbourne web hosting, free domain name, unlimited data transfer, unlimited emails, PHP, ASP, and database hosting,check Web Hosting Melbourne services.

Wednesday, November 28th, 2007

Table 8-1: Summary of Important Servlet and JSP Methods Servlet or Method JSP init Servlet jspInit JSP service Servlet doGet Servlet doPost Servlet destroy Servlet jspDestroy JSP Required Description/Notes No Performs one-time initializations. No Same as init. JSP author may provide code in JSP. No Handles the request. Not a good idea to code an implementation _jspService JSP Yes Handles the HTTP request from the JSP page. The JSP author does not have to implement it. It is implemented by the JSP translator. No Handles an HTTP GET request. Required only if the servlet must handle GET requests. No Handles an HTTP POST request. Required only if the servlet must handle POST requests. No Performs cleanup immediately prior to servlet purge by server. No Performs cleanup immediately prior to JSP purge by server.
The UK economy was the first in the world to enter the Industrial Revolution, and initially concentrated on heavy industry such as shipbuilding, coal mining, steel production and textiles.All our UK Web Hosting plans are very cheap and they fully support PHP mysql Dreamweaver frontpage and much more.

servers use a configuration file, whereas others use a GUI to set values for server settings. Note the bolded invocation of the superclass constructor in the second example. Do yourself a favor and code the call to super.init as the first line in your init implementation when you require an object of ServerConfig. As with init, jspInit is not required for JSP execution. However, you can code a jspInit method in your JSP page, which is passed to the generated servlet. The servlet engine executes the jspInit method only once upon loading the generated servlet. Listing 8-4 shows how to code a jspInit method in your JSP pages. Listing 8-4: Example of jspInit method in a JSP jspInit

Tuesday, November 27th, 2007

<%! String hello = "Dummy Value"; public void jspInit() { hello = "Initial value 'Hello World' changed in jspInit()" ; }%> Java variable hello is now <%= hello %> When this page runs, the initial value of Dummy Value is changed by the assignment inside the jspInit method. In a real-world application, you would not see one simple String value overriding another, as is seen in this listing. You might override the Dummy Value with information retrieved from a bean or a database, depending on your application needs. Rather than show you the vast amount of code generated by the JSP translator here, please take my word that this generated servlet contains a jspInitmethod. Examining the destroy and jspDestroy Methods It is unnecessary for you to code an implementation of the destroy method for your servlets. However, if you do, the server invokes your destroy method before unloading your servlet. The destroy method is a good place to perform various cleanup activities, such as closing database connections and writing any remaining persistent data to disk. The JSP equivalent to destroy is jspDestroy. As with destroy, jspDestroy is not required for JSP execution. The jspDestroy method serves the same purpose as the destroy method for “raw” servlets. As with jspInit, you may code an implementation of jspDestroy in your page, or use a page directive to include an implementation. A good rule of thumb is that if you code a jspInit method that grabs resources, such as pooled database connections, you should code a jspDestroymethod to release the grabbed resources. Note Other than jspInit and jspDestroy, you cannot code methods that start with jsp, jspx, _jsp, or _jspx. These method prefixes are reserved for future use by Sun. Examining the service and _jspService Methods You do not need to code an implementation of the service method. In fact, it is best if you do not override service. Instead, it is more effective to override the doGet and doPost methods. Your main advantages of overriding doGet and doPost as opposed to overriding service are as follows: . You can add other do methods more easily when you override doGet and doPost. Overriding service removes your ability to add these other methods easily, especially if your servlet is then subclassed. . You have automatic support for various requests, such as TRACE and OPTIONS requests, even if your servlet is subclassed. The accepted way of overriding the same action for a POST or GET is to override doGet and doPost in a servlet and have doPost invoke doGet, or vice versa. (Refer to Listing 8-1 for an example of doPost calling doGet.) The _jspService method is required for JSP execution. However, you must never code a _jspService method. The _jspService method is automatically generated by the JSP translator. _jspService is the “meat and potatoes” of the JSP; most of your JSP code finds its way into the _jspService method. Table 8-1 summarizes the servlet and JSP methods discussed in the preceding sections.
Our company is website hosting provider which offers web hosting services for php, java, mysql, frontpage, dreamweaver and domain name registration. Check more about us on website hosting provider part.

HttpSession session = null; ServletContext application = null; ServletConfig config = null; JspWriter out = null; Object page = this; String _value = null; try { if (_jspx_inited == false) { _jspx_init(); _jspx_inited = true; } _jspxFactory = JspFactory.getDefaultFactory(); response.setContentType(”text/html”); pageContext = _jspxFactory.getPageContext(this, request, response, “”, true, 8192, true); application = pageContext.getServletContext(); config = pageContext.getServletConfig(); session = pageContext.getSession(); out = pageContext.getOut(); /* HTML begin [file=”D:\tomcat32\Webapps\examples\jsp\loutest\loutest.jsp”;from=(0,35);to=(7,0)] */ out.write(”rnrnrnMinimal JSP Page

Monday, November 26th, 2007

rnrnrnrn”); // end/* HTML begin [file=”D:\tomcat32\Webapps\examples\jsp\loutest\loutest.jsp”;from=(7,36);to=(8,0)] */ out.write(”rn”); // end/* HTML begin [file=”D:\tomcat32\Webapps\examples\jsp\loutest\loutest.jsp”;from=(8,3);to=(8,10)] */ out.print( hello ); // end/* HTML begin [file=”D:\tomcat32\Webapps\examples\jsp\loutest\loutest.jsp”;from=(8,12);to=(12,0)] */ out.write(”rnrnrnrn”); // end } catch (Exception ex) { if (out.getBufferSize() != 0) out.clearBuffer(); pageContext.handlePageException(ex); } finally { out.flush(); _jspxFactory.releasePageContext(pageContext); } } } Whew! What is the reason for showing the generated code? The first reason is to demonstrate the labor and toil expended in generating a servlet from a very small JSP page. Second, examining generated code is best left to computers, not humans don t you agree? Note the absence of jspInit, jspDestroy, doGet, and doPost methods in the generated servlet (or take my word for it!). Also, take note that the bolded lines are generated in response to the JSP code in the page. Because an implementation of the init method is not required for servlet execution and an implementation for the jspInit method is not required for JSP execution, why would you implement these two methods? You can discover why in the next section. Examining the init and jspInit Methods As previously mentioned, the init method is called when the servlet first loads. The init method is not called for each user request. Hence, init is used to perform one-time initializations. Actually, Java applets have an init method, which is not required, that serves the same function as init for servlets. You may code the init method sans arguments as follows: public void init() throws ServletException { Also, you may pass an object of ServletConfig to init as follows: public void init( ServletConfig sConfig) throws ServletException { super.init( sConfig ) ; You would use the second signature for init when your servlet requires server settings. Creating server settings is dependent on the server being used. Some
If you are looking quality, fast, secure and reliable web hosting with PHP service at an affordable price, check php5 hosting services.

{ doGet( request, response ) ; }} The above servlet is as bare bones as it gets. It is important to note that you do not have to override the doGet or doPost methods if you instead override the service method and handle all requests there. This would not be considered good form in servlet design, but it is an option. In the next section we will see that a minimal JSP-generated servlet is a bit different since the doGet and doPost methods do not exist. Writing a Minimal JSP-Generated Servlet The nuts and bolts of a JSP-generated servlet are dependent on the JSP-to-servlet translator used with a particular Web server. Listing 8-2 shows a rather simple JSP page in which Tomcat 3.2 generated the servlet. However, this page is not the simplest because it has actual JSP scripting elements a simple page would have nothing but static text. Listing 8-2: A simple JSP page with a couple of scripting elements Minimal JSP Page

Sunday, November 25th, 2007

<%! String hello = "Hello World"; %> <%= hello %> Listing 8-3 shows the servlet that Tomcat generates from the JSP page in Listing 8-2. Listing 8-3: JSP-generated servlet for minimal JSP page in Listing 8-2 package jsp.loutest; import javax.servlet.*; import javax.servlet.http.*; import javax.servlet.jsp.*; import javax.servlet.jsp.tagext.*; import java.io.PrintWriter; import java.io.IOException; import java.io.FileInputStream; import java.io.ObjectInputStream; import java.util.Vector; import org.apache.jasper.runtime.*; import java.beans.*; import org.apache.jasper.JasperException; public class _0002fjsp_0002floutest_0002floutest_0002ejsploutest_jsp_7extends HttpJspBase { /* begin [file=”D:\tomcat32\Webapps\examples\jsp\loutest\loutest.jsp”;from=(7,3);to=(7,34)] */ String hello = “Hello World”; // end static { } public _0002fjsp_0002floutest_0002floutest_0002ejsploutest_jsp_7( ) { } private static boolean _jspx_inited = false; public final void _jspx_init() throws JasperException { } public void _jspService(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { JspFactory _jspxFactory = null; PageContext pageContext = null;
We specialize in RedHat Linux Apache web server technology for site owners and site developers and all our hosting packages come with a wide range of features as standard including automatic backups, visitor statistics, spam filtering, email anti virus and much more. Web Hosting Apache.Try us out!

Saturday, November 24th, 2007

EJB & JSP: Java On The Edge, Unlimited Edition by Lou Marco ISBN: 0764548026 Your Guide to Cutting-Edge J2EE Programming Techniques. Chapter 8: JSPs and Servlets Revisited In previous chapters, you ve read much about the relationship between JavaServer Pages and Java servlets. In this chapter, you can take a closer look at this relationship. You can delve into the servlet life cycle and discover the differences between a raw servlet and a JSP-generated servlet. You can also read about important servlet and JSP methods, along with learning about the servlet environment. In addition, you can gain insight into why you need to use servlets, which is discussed in this chapter s section on using Java servlets and JSPs together. Examining the Servlet Life Cycle Because JSPs get translated into Java servlets, the JSP life cycle closely parallels that of servlets. In brief, when you request a JSP page, the translator generates a servlet and the Java compiler on the server compiles the generated servlet. Then the server invokes the class loader to load the servlet and start execution. If the servlet contains an init method, the container calls it. The init method runs only once. You can see that, for JSP-generated servlets, the analogue for the servlet init method is called jspInit. Both init and jspInit are optional methods. After execution of init or jspInit, the servlet executes its service method. The JSP equivalent for the service method is _jspService. The server can run multiple threads accessing the service or the _jspService method simultaneously, or you can force the server to single thread the method s access by using a single-threaded model using the isThreadSafe attribute of the page directive. Next, in servlets the service method invokes either the doGet or doPost method. The doGet and doPost methods of the servlet implement the get and post requests made from the client browser to the servlet, respectively. JSP-generated servlets do not have implementations for doPost and doGet. JSP- generated servlets perform both post and get requests in the _jspService method. Actually, a servlet can implement various do methods depending on the particulars of the HTTP request, such as doPut and doDelete methods. When the server unloads a servlet, the server invokes the destroy method. The JSP-generated equivalent to the destroy method is jspDestroy. As with init and jspInit, destroy and jspDestroy are optional. Writing the Minimal Servlet Given that most of the servlet methods discussed above are optional, you may wonder what is the smallest or minimal servlet? Listing 8-1 provides an example of a minimal servlet. Listing 8-1: A contender for the minimal servlet import java.io.* ; import java.text.* ; import java.util.* ; import javax.servlet.* ; import javax.servlet.http.* ; public class minimalServlet extends HttpServlet { public void doGet( HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { response.setContentType(”text/html”) ; PrintWriter out = response.getWriter() ; out.println(” Hello World ” ) ; out.close() ; } public void doPost( HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
If you are in search for clan hosting account you just came in to right place. We host many clan websites in almost all popular games like Counterstrike, Call Of Duty and other. More details about our offer you can find inside clan web hosting section.

Friday, November 23rd, 2007

Servlets and JSP pages use cookies by default to manage sessions. A cookie is a set of values, a name-value pair, which is sent to a client. Cookie implementations usually involve files stored on the client machine, and the location of such files is browser dependent. It is important to remember that cookies can t be trusted to maintain sessions. For example, the client machine may have cookies disabled. In this situation, the servlet can use a technique called URL rewriting, which involves encoding the session key in the request URL. The servlet can decode the URL to extract the session key, thereby identifying the appropriate client belonging to that particular session. Encoding and Parsing Form Data Data sent with a get or post request may be encoded in a scheme known as URL encoding. The encoding replaces special characters, such as spaces and unprintable characters, with symbols and hex values. Names and values are encoded separately. You ve seen this encoding on search engines before. For example, an advanced search in the Google search engine (http://www.google.com/) encodes search parameters as follows: http://www.google.com/search?as_q=quantum+computing&num=10&btnG=Google+Search&as_oq=&as_epq=&as_eq=&as_occt=title&lr=&as_dt=i&sitesearch=&safe=off Notice the name-value pairs (q=quantum+computing) with the + symbol replacing the blank, the & symbol connecting multiple search criteria, and the setting of hidden parameters (safe=off). Servers are capable of automatically decoding this data. Whether the data is sent by a getrequest or post request, your JSP page can decode and retrieve the data by using the getParameter method of the request object. For example, the JSP expression shown below retrieves the value of the q parameter: <%= request.getParameter("q") %> Using the above method eliminates the necessity of writing code to parse the data or having to use the java.net.URLEncoder and java.net.URLDecoder classes. Accessing Shared Data JSPs and servlets may exchange data by using a set of methods available to objects of class ServletContext. In JSP lingo, the application scope represents objects derived from class ServletContext. Some of these methods are getAttribute, getAttributeNames, setAttribute, and removeAttribute. Servlets and JSPs also can share initialization parameters and configuration settings by using methods available to objects of class ServletConfig, such as getInitParameter and getInitParameterNames. Your Web server may have additional methods to expose various properties and attributes of your server environment to your JSP pages. Servlets provide the JSP programmer with powerful features that are accessed with standard JSP expressions. You may think that you ll never have to code a servlet because all your dynamic Web page content needs are addressed by JSP. Although JSP brings unparalleled abilities to the Web application developer, you shouldn t throw out that servlet API documentation just yet. The following section touches on some cases in which you may want to use Java servlets with your JSPs.
Do you have a godaddy domain name? If you do, you have found the right web hosting provider for you.Our Godaddy Web Hosting packages are the best match to well known, affordable godaddy domain names.

Thursday, November 22nd, 2007

EJB & JSP: Java On The Edge, Unlimited Edition by Lou Marco ISBN: 0764548026 Your Guide to Cutting-Edge J2EE Programming Techniques. Using the JSP/Servlet Environment Now that we have reviewed the methods related to the JSP and servlet life cycles, let’s take a close look at the environment in which they exist. Understanding the JSP/servlet environment will help us to better leverage the features of this environment that are useful for writing robust Web applications. Figure 8-1 depicts the relevant environmental components and the request/response flow between clients, JSPs, and servlets. Figure 8-1: A high-level view of JSP and servlet processing HTTP, FTP, or any other supported protocol request type originates from a browser (client) and is sent to the Web server. The JSP-enabled server recognizes the .jsp extension and realizes that the request is packaged with a JavaServer Page. The server translates the JSP page into a servlet. Along the way, the original request gets passed to the _jspService method in the generated servlet. After the servlet executes, perhaps by communicating with other Java components such as JavaBeans, the servlet returns a response in the form of an HTML, XML, plain text, or other MIME- type resource. Useful Servlet Environment Features The servlet environment provides important features to JSP pages. This section describes some of these features. Session Management One advantage of using servlets and, as a result, JSPs, is that servlets provide session management services. Recall that a session is a connection between a client and a server that enables the two to share data. The server identifies sessions by using a session key, which the server stores in a dictionary-type object.
We are here to provide web hosting at an affordable rate for the online Christian community. The term “Christian” is used by various groups with diverse beliefs to describe themselves. Some people, including many born-again Christians, use a fairly specific definition of “Christian”. They believe that in order to be a Christian, one must follow Jesus, and that the proof of this is found in agreeing to and following the doctrines set forth in the Bible. Others who refer to themselves as Christians require only that one believes that Jesus is the Son of God, that he died, and that he was resurrected from the dead, to claim the term Christian.Check Christian Web Hosting section.

Wednesday, November 21st, 2007

accessing a Java component in addition to dispatching requests and fetched data (from other components) to some JSP pages or other servlets. Forwarding Requests from Servlets In the recent past, the Java servlet programmer did not have a convenient way of implementing the preceding approach. But with the release of the Servlet API 2.1, the Java programmer can implement the RequestDispatcherinterface. Implementations of RequestDispatcher are available at ServiceContext and can be used to send a request to a static resource (an HTML page, for example) or a dynamic resource (a JSP or servlet, for example). The servlet programmer has two methods to implement: forward, to transfer control to another resource; or include, to handle the overall management of the request from, and the response to, the client. The code, shown in the following, forwards a request from a servlet to a JSP: //Assume request and response have their usual meaningRequestDispatcher rDisp = getServletContext().getRequestDispatcher(”myJSPPage.jsp”); rDisp.forward(request, response ) ; The URL argument in getRequestDispatcher is a relative path URL.
Our facility is located in Orlando, Florida. Our Orlando web hosting data center gives you assurance that your website will work smoothly . Check more in Orlando Web Hosting.

Tuesday, November 20th, 2007

EJB & JSP: Java On The Edge, Unlimited Edition by Lou Marco ISBN: 0764548026 Your Guide to Cutting-Edge J2EE Programming Techniques. Using JSPs with Servlets You ve learned about JSP pages containing Java code that gets passed to servlets. You ve witnessed JSPs using JavaBeans. You ve seen examples of JSP custom-tag libraries. By now, you ve discovered quite a lot about JavaServer Pages. But is there anything in the realm of generating dynamic Web content that JSPs cannot do? More specifically, does a situation exist in which using only JSPs to generate dynamic Web content is not the best solution? JSP development assumes that your pages have a common presentation style and theme. JSPs may be inadequate at providing dramatically different looks based on different user inputs or different data. A JSP page that effectively displays data as an HTML table may do a poor job displaying data as an animated chart. Then what is one to do? Although opinions may differ, you can leverage servlets to help your JSP page development in some situations. A servlet may start the dynamic content preparation process and then forward the request to one or more JSPs to complete the presentation. In the Model 2 approach, the Model-View-Controller pattern is applied to this situation by having a servlet act as the controller, the beans as the model, and the JSPs as the view. A more recent point of view embraces the idea of a server acting as a dispatcher of requests to JSPs and other Java container objects, such as Enterprise JavaBeans. Appropriately, the term used to describe the above-cited point of view is called the Dispatcher approach, which is illustrated in Figure 8-2. Figure 8-2: A servlet acting as a dispatcher As Figure 8-2 shows, the servlet captures the request and manages the application flow. The dispatching servlet may not be responsible for generating any dynamic presentation content. Figure 8-2 shows the dispatching servlet
We offer quality web hosting with only $3.99 per month with unlimited email addresses, unlimited bandwidth, and unlimited server space. Check our web hosting unlimited bandwidth section.