<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.0.4" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title>Web Hosting Wordpress Blog</title>
	<link>http://www.visionwebhosting.net/blog</link>
	<description>Blog about news in web hosting industry</description>
	<pubDate>Mon, 26 May 2008 10:08:40 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.4</generator>
	<language>en</language>
			<item>
		<title>hello long time not see</title>
		<link>http://www.visionwebhosting.net/blog/2008/05/26/hello-long-time-not-see/</link>
		<comments>http://www.visionwebhosting.net/blog/2008/05/26/hello-long-time-not-see/#comments</comments>
		<pubDate>Mon, 26 May 2008 10:08:40 +0000</pubDate>
		<dc:creator>sales</dc:creator>
		
	<category>Web Hosting</category>
		<guid isPermaLink="false">http://www.visionwebhosting.net/blog/2008/05/26/hello-long-time-not-see/</guid>
		<description><![CDATA[After long time we will start working on this blog again. Be prepared 

]]></description>
			<content:encoded><![CDATA[<p>After long time we will start working on this blog again. Be prepared <img src='http://www.visionwebhosting.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />
</p>
]]></content:encoded>
			<wfw:commentRSS>http://www.visionwebhosting.net/blog/2008/05/26/hello-long-time-not-see/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>getServletContext().getAttribute( attribute )); } private String getServerInfoName(String serverInfo) { int</title>
		<link>http://www.visionwebhosting.net/blog/2007/02/04/getservletcontextgetattribute-attribute-private-string-getserverinfonamestring-serverinfo-int/</link>
		<comments>http://www.visionwebhosting.net/blog/2007/02/04/getservletcontextgetattribute-attribute-private-string-getserverinfonamestring-serverinfo-int/#comments</comments>
		<pubDate>Mon, 05 Feb 2007 02:26:11 +0000</pubDate>
		<dc:creator>sales</dc:creator>
		
	<category>servlet</category>
		<guid isPermaLink="false">http://www.visionwebhosting.net/blog/2007/02/04/getservletcontextgetattribute-attribute-private-string-getserverinfonamestring-serverinfo-int/</guid>
		<description><![CDATA[getServletContext().getAttribute( attribute )); }    private String getServerInfoName(String serverInfo) { int slash = serverInfo.indexOf( / ); if (slash == -1) return serverInfo; else return serverInfo.substring(0, slash);   }   private String getServerInfoVersion(String serverInfo) { int slash = serverInfo.indexOf( / ); if (slash == -1) return null; else return serverInfo.substring(slash + 1); [...]]]></description>
			<content:encoded><![CDATA[<p>getServletContext().getAttribute( attribute )); }    private String getServerInfoName(String serverInfo) { int slash = serverInfo.indexOf( / ); if (slash == -1) return serverInfo; else return serverInfo.substring(0, slash);   }   private String getServerInfoVersion(String serverInfo) { int slash = serverInfo.indexOf( / ); if (slash == -1) return null; else return serverInfo.substring(slash + 1);   } }   This servlet also directly subclasses GenericServlet, demonstrating that all the information about a server  is available to servlets of any type. The servlet outputs simple raw text. When accessed, this servlet prints  something like:   req.getServerName(): localhost req.getServerPort(): 8080 getServletContext().getServerInfo(): JavaWebServer/1.1.1 getServerInfo() name: JavaWebServer getServerInfo() version: 1.1.1 getServletContext().getAttribute(&#8221;attribute&#8221;): null   Unfortunately, there is no server-independent way to determine the server&#8217;s root directory, referred to in this  book as server_root. However, some servers including the Java Web Server save the server&#8217;s root  directory name in the server.rootsystem property, where it can be retrieved using  System.getProperty( server.root ).   Locking a Servlet to a Server   This server information can be put to more productive uses. Let&#8217;s assume you&#8217;ve written a servlet and you don&#8217;t  want it running just anywhere. Perhaps you want to sell it and, to limit the chance of unauthorized copying, you  want to lock the servlet to your customer&#8217;s machine with a software license. Or, alternatively, you&#8217;ve written a  license generator as a servlet and want to make sure it works only behind your firewall. This can be done  relatively easily because a servlet has instant access to the information about its server.   Example 4-4 shows a servlet that locks itself to a particular server IP address and port number. It requires an  init parameter key that is appropriate for its server IP address and port before it unlocks itself and handles a  request. If it does not receive the appropriate key, it refuses to continue. The algorithm used to map the key to  the IP address and port (and vice-versa) must be secure.   Example 4-4. A servlet locked to a server   import java.io.*; import java.net.*; import java.util.*; import javax.servlet.*;   public class KeyedServerLock extends GenericServlet {   // This servlet has no class or instance variables // associated with the locking, so as to simplify // synchronization issues.    <br />Hint: If you are looking for good and high quality web space to host and run your java application check Vision <a target="_blank" href="http://www.visionwebhosting.net">java web hosting</a> services
</p>
]]></content:encoded>
			<wfw:commentRSS>http://www.visionwebhosting.net/blog/2007/02/04/getservletcontextgetattribute-attribute-private-string-getserverinfonamestring-serverinfo-int/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>There are four methods that a servlet can</title>
		<link>http://www.visionwebhosting.net/blog/2007/02/04/there-are-four-methods-that-a-servlet-can/</link>
		<comments>http://www.visionwebhosting.net/blog/2007/02/04/there-are-four-methods-that-a-servlet-can/#comments</comments>
		<pubDate>Sun, 04 Feb 2007 16:01:50 +0000</pubDate>
		<dc:creator>sales</dc:creator>
		
	<category>servlet</category>
		<guid isPermaLink="false">http://www.visionwebhosting.net/blog/2007/02/04/there-are-four-methods-that-a-servlet-can/</guid>
		<description><![CDATA[There are four methods that a servlet can use to learn about its server: two that are called using the  ServletRequestobject passed to the servlet and two that are called from the ServletContextobject in  which the servlet is executing. A servlet can get the name of the server and the port number for [...]]]></description>
			<content:encoded><![CDATA[<p>There are four methods that a servlet can use to learn about its server: two that are called using the  ServletRequestobject passed to the servlet and two that are called from the ServletContextobject in  which the servlet is executing. A servlet can get the name of the server and the port number for a particular  request with getServerName()and getServerPort(), respectively:   public String ServletRequest.getServerName()  public int ServletRequest.getServerPort()   These methods are attributes of ServletRequestbecause the values can change for different requests if the  server has more than one name (a technique called virtual hosting). The returned name might be something like   www.servlets.com&#8221; while the returned port might be something like  8080 .   The getServerInfo()and getAttribute()methods of ServletContextprovide information  about the server software and its attributes:   public String ServletContext.getServerInfo()  public Object ServletContext.getAttribute(String name)   getServerInfo()returns the name and version of the server software, separated by a slash. The string  returned might be something like  JavaWebServer/1.1.1 . getAttribute()returns the value of the  named server attribute as an Objector nullif the attribute does not exist. The attributes are server- dependent. You can think of this method as a back door through which a servlet can get extra information about  its server. Attribute names should follow the same convention as package names. The package names java.* and javax.*are reserved for use by the Java Software division of Sun Microsystems (formerly known as  JavaSoft), and com.sun.*is reserved for use by Sun Microsystems. See your server&#8217;s documentation for a list  of its attributes. Because these methods are attributes of ServletContextin which the servlet is executing,  you have to call them through that object:   String serverInfo = getServletContext().getServerInfo();   The most straightforward use of information about the server is an &#8220;About This Server&#8221; servlet, as shown in  Example 4-3.   Example 4-3. Snooping the server   import java.io.*; import java.util.*; import javax.servlet.*;   public class ServerSnoop extends GenericServlet {   public void service(ServletRequest req, ServletResponse res)  throws ServletException, IOException {  res.setContentType( text/plain );  PrintWriter out = res.getWriter();   out.println( req.getServerName():   + req.getServerName());   out.println( req.getServerPort():   + req.getServerPort()); out.println( getServletContext().getServerInfo():   + getServletContext().getServerInfo()); out.println( getServerInfo() name:   + getServerInfoName(getServletContext().getServerInfo())); out.println( getServerInfo() version:   + getServerInfoVersion(getServletContext().getServerInfo()));  out.println( getServletContext().getAttribute( attribute ):   +    <br />Note: If you are looking for inexpensive but high quality provider to host and run your serlvet application check Astra <a target="_blank" href="http://www.omnicus.net/">servlet hosting</a> services
</p>
]]></content:encoded>
			<wfw:commentRSS>http://www.visionwebhosting.net/blog/2007/02/04/there-are-four-methods-that-a-servlet-can/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>Example 4-2. Getting init parameter names import java.io.*;</title>
		<link>http://www.visionwebhosting.net/blog/2007/02/03/example-4-2-getting-init-parameter-names-import-javaio/</link>
		<comments>http://www.visionwebhosting.net/blog/2007/02/03/example-4-2-getting-init-parameter-names-import-javaio/#comments</comments>
		<pubDate>Sun, 04 Feb 2007 03:59:44 +0000</pubDate>
		<dc:creator>sales</dc:creator>
		
	<category>servlet</category>
		<guid isPermaLink="false">http://www.visionwebhosting.net/blog/2007/02/03/example-4-2-getting-init-parameter-names-import-javaio/</guid>
		<description><![CDATA[Example 4-2. Getting init parameter names   import java.io.*; import java.util.*; import javax.servlet.*;   public class InitSnoop extends GenericServlet {   // No init() method needed   public void service(ServletRequest req, ServletResponse res)  throws ServletException, IOException {  res.setContentType( text/plain );  PrintWriter out = res.getWriter();   out.println( Init [...]]]></description>
			<content:encoded><![CDATA[<p>Example 4-2. Getting init parameter names   import java.io.*; import java.util.*; import javax.servlet.*;   public class InitSnoop extends GenericServlet {   // No init() method needed   public void service(ServletRequest req, ServletResponse res)  throws ServletException, IOException {  res.setContentType( text/plain );  PrintWriter out = res.getWriter();   out.println( Init Parameters: );  Enumeration enum = getInitParameterNames();  while (enum.hasMoreElements()) {  String name = (String) enum.nextElement();   out.println(name +  :   + getInitParameter(name)); } } }   Notice that this servlet directly subclasses GenericServlet, showing that init parameters are available to  servlets that aren&#8217;t HTTP servlets. A generic servlet can be used in a web server even though it lacks any  support for HTTP-specific functionality.   Unfortunately, there&#8217;s no server-independent way for a servlet to ask for its registered name or its class file  location. This information may be added in a future version of the Servlet API. Until then, although it&#8217;s not  pretty, this information can be passed using init parameters where necessary. Also, some servers including the  Java Web Server provide a back door whereby a servlet can get its registered name. If a servlet defines a  method with the following signature, the server calls it and passes it the servlet&#8217;s registered name at  initialization:   public void setServletName(String name);   The servlet can save the passed-in name and use it later. You&#8217;ll notice this back door was built without changing  the Servlet API, a necessary requirement because, by the time it was added, the Servlet API 2.0 had already  been frozen.   The Server   A servlet can find out much about the server in which it is executing. It can learn the hostname, listening port,  and server software, among other things. A servlet can display this information to a client, use it to customize  its behavior based on a particular server package, or even use it to explicitly restrict the machines on which the  servlet will run.   Getting Information about the Server    <br /> Note: If you are looking for good and quality webspace to host and run your java application check professional <a target="_blank" href="http://www.webhostingjava.net/">java hosting</a> services
</p>
]]></content:encoded>
			<wfw:commentRSS>http://www.visionwebhosting.net/blog/2007/02/03/example-4-2-getting-init-parameter-names-import-javaio/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>Each registered servlet name can have specific initialization</title>
		<link>http://www.visionwebhosting.net/blog/2007/02/03/each-registered-servlet-name-can-have-specific-initialization/</link>
		<comments>http://www.visionwebhosting.net/blog/2007/02/03/each-registered-servlet-name-can-have-specific-initialization/#comments</comments>
		<pubDate>Sat, 03 Feb 2007 17:26:58 +0000</pubDate>
		<dc:creator>sales</dc:creator>
		
	<category>servlet</category>
		<guid isPermaLink="false">http://www.visionwebhosting.net/blog/2007/02/03/each-registered-servlet-name-can-have-specific-initialization/</guid>
		<description><![CDATA[Each registered servlet name can have specific initialization (init) parameters associated with it. Init parameters  are available to the servlet at any time; they are often used in init ()to set initial or default values for a  servlet or to customize the servlet&#8217;s behavior in some way. Init parameters are more fully explained [...]]]></description>
			<content:encoded><![CDATA[<p>Each registered servlet name can have specific initialization (init) parameters associated with it. Init parameters  are available to the servlet at any time; they are often used in init ()to set initial or default values for a  servlet or to customize the servlet&#8217;s behavior in some way. Init parameters are more fully explained in Chapter  3, The Servlet Life Cycle.   Getting an Init Parameter   A servlet uses the getInitParameter()method to get access to its init parameters:   public String ServletConfig.getInitParameter(String name)   This method returns the value of the named init parameter or nullif it does not exist. The return value is  always a single String. It is up to the servlet to interpret the value.   The GenericServletclass implements the ServletConfiginterface and thus provides direct access to  the getInitParameter()method.* The method is usually called like this:   public void init(ServletConfig config) throws ServletException {  super.init(config);  String greeting = getInitParameter(&#8221;greeting&#8221;);  }   A servlet that needs to establish a connection to a database can use its init parameters to define the details of the  connection. We can assume a custom establishConnection()method to abstract away the details of  JDBC, as shown in Example 4-1.   * The servlet must call super.init(config)in its init()method to get this functionality.  Example 4-1. Using init parameters to establish a database connection   java.sql.Connection con = null;   public void init(ServletConfig config) throws ServletException { super.init(config);   String host = getInitParameter( host ); int port = Integer.parseInt(getInitparameter( port )); String db = getInitParameter( db ); String user = getInitParameter( user ); String password = getInitParameter( password ); String proxy = getInitParameter( proxy );    con = establishConnection(host, port, db, user, password, proxy); }   Getting Init Parameter Names   A servlet can examine all its init parameters using getInitParameterNames():   public Enumeration ServletConfig.getInitParameterNames()   This method returns the names of all the servlet&#8217;s init parameters as an Enumerationof Stringobjects or  an empty Enumerationif no parameters exist. It&#8217;s most often used for debugging.   The GenericServletclass also makes this method directly available to servlets. Example 4-2 shows a  servlet that prints the name and value for all of its init parameters.    </p>
<p>Hint: This post is supported by Gama <a target="_blank" href="http://www.webhostingphp.net/">web hosting php mysql</a> provider
</p>
]]></content:encoded>
			<wfw:commentRSS>http://www.visionwebhosting.net/blog/2007/02/03/each-registered-servlet-name-can-have-specific-initialization/feed/</wfw:commentRSS>
		</item>
	</channel>
</rss>
