iWiz ShareBase

IT Specialist À±ÅÂÇöÀÇ iWiz ShareBase´Â IT»Ó ¾Æ´Ï¶ó °¢Á¾ Àâ´ÙÇÑ Áö½ÄµéÀ» ÇÔ²² ³ª´©´Â Áö½Ä°øÀ¯ Ä¿¹Â´ÏƼÀÔ´Ï´Ù.

iWiz,ShareBase,À±ÅÂÇö,Java,JSP,EJB,IT,Á¤º¸±â¼ú,À¥ÇÁ·Î±×·¡¹Ö,PHP,ASP,DBMS,MySQL,¼­¹ö,³×Æ®¿öÅ©,server,network,WAS,À¥¾ÖÇø®ÄÉÀ̼Ç,ºí·Î±×,blog,À¥¼­¹ö,DB,¿À¶óŬ,oracle,mysql,JRun,À¥·ÎÁ÷,ÅèĹ,tomcat,¾ÆÆÄÄ¡,ÀÚµ¿Â÷,EF½î³ªÅ¸,·Î¶Ç 6/45

°¶·¯¸® Pixelgrapher.com | ·Î¶Ç 6/45 ¹øÈ£»ý¼º ¹× Åë°è µ¥ÀÌÅÍ | Àüü±â»çº¸±â | Àüü±Û #1 | Àüü±Û #2 | Àüü±Û #3 | Àüü±Û #4 | Àüü±Û #5 | Àüü±Û #6 | Àüü±Û #7 | Àüü±Û #8 | Àüü±Û #9 | Àüü±Û #10 |
HOME iWiz
ShareBase
Remember 0523 & 0818
Áö½ÄÀº ³ª´­¼ö·Ï Ä¿Áý´Ï´Ù - iWiz's ShareBase
À¥ÇÁ·Î±×·¡¹Ö(±âŸ) PHP, ASP, Perl, CGI µî °¢Á¾ À¥ÇÁ·Î±×·¡¹Ö¿¡ °üÇÑ ÀÚ·áµéÀÔ´Ï´Ù.


  iWiz(2004-01-04 22:39:32, Hit : 9445, Vote : 31
 http://www.wz.pe.kr

Optimizing JSPs


Optimizing JSPs

This section presents some ideas for improving the responsiveness of your JSPs.

Since JSPs are compiled into servlets when they are first requested, look at the optimization techniques for servlets for additional ideas. For more information, see "Optimizing servlets".

Precompiling JSPs

Unlike servlets, which are compiled before deployment, JSP pages are compiled by JRun the first time they are requested. This can cause an apparent lag, which can appear to some users as slow responsiveness. JRun provides the option of precompiling the JSPs.

The JSPC compiler is a command-line tool that you use to compile JSPs outside the context of a web server. With the JSPC compiler, you can explicitly compile JSPs from a command line, rather than use JRun to compile them upon a request of the JSP. JSPC uses the IBM jikes compiler if it is located in the jrun_root/bin directory. Otherwise, it uses the Sun javac compiler.

When precompiling JSPs, it is also a good idea to disable JRun's autodetection of changes to those files. For more information, see "Disabling change detection".

Note:   The JSPC compiler is the same compiler that JRun uses to compile JSPs. The only difference is that you invoke the JSPC compiler from a command line.

For more information on using the JSPC compiler, see the JRun Assembly and Deployment Guide.

Disabling change detection

By default, JRun cycles through web component files (like servlets and JSPs) to detect if the files have changed since the last cycle. This process is what makes hot deployment and autodetecting changes work. However, this cycling also degrades performance and should be disabled in a production environment. It is especially unnecessary if you precompile your JSPs, as described in "Precompiling JSPs".

To disable the autodetection of changes for JSPs, set the JSPServlet's translationDisabled initialization parameter in the default-web.xml file to true, as the following example shows:

<servlet>
   <servlet-name>JSPServlet</servlet-name>
   <servlet-class>jrun.jsp.JSPServlet</servlet-class>
   <load-on-startup>1</load-on-startup>
   <init-param>
     <param-name>keepGenerated</param-name>
     <param-value>false</param-value>
   </init-param>
   <init-param>
     <param-name>translationDisabled</param-name>
     <param-value>true</param-value>
   </init-param>  
 </servlet>

Caching static data in the ServletContext object

The ServletContext object stores objects as attributes. By caching objects, such as hashtables or other structures, you reduce the processing load of your application.

The implicit application object in a JSP represents the ServletContext for that JSP. You do not have to execute a method to get the ServletContext as you do in servlets. For example, the following code sets an attribute to the ServletContext object in a JSP:

application.setAttribute("statelist", qt);

If you use the jrun:sql tag in the JRun Tag Library to get a QueryTable, you can store the QueryTable object as an application attribute. You do not have to convert the ResultSet to a Hashtable or other serializable object.

The ServletContext object behaves the same with JSPs as it does with servlets. For more information, see "Caching static data in the ServletContext object".

Disabling sessions

Every time a JSP is requested, JRun creates an HttpSession object to maintain state for each unique client. The session data is accessible in the JSP as the implicit session object. In JSPs, sessions are enabled by default.

Each session object uses up a small amount of system resources, because it is stored on the server. In addition, traffic between the client and server must include the session ID when sessions are enabled. This adds a small amount of overhead.

Use the page directive to disable sessions. Set the session attribute of the page directive to false, as shown in the following example:

<%@ page session="false" %>

Increasing response object's buffer

Increase the size of the response object's buffer to reduce socket creation.

The default size of the JSP response buffer is 8kb. JRun flushes the buffer whenever the response size reaches at least this size. Set the buffer to a larger value to reduce the number of flushes necessary, as shown in the following example:

<%@ page buffer="16kb" %>

The page directive applies to an entire JSP page and any of its included files.

To check the size of the buffer, use the getBufferSize method of the implicit response object, as shown in the following example:

Buffer size is <%= response.getBufferSize() %>

Using includes correctly

Whenever possible, use the include directive rather than the include action when including static pages. The include directive inserts the contents of the included file at compile time (in the case of JSPs, the first time the page is requested), whereas the include action fetches the included file during runtime (every time the page is requested). The latter requires more processing on the server side.

For example, if you have a static file, header.html, include the file using the include directive, as shown in the following example:

<%@ include file="/static-pages/header.html" %>

Do not include the static file with an include action, as shown in the following example:

<jsp:include page="/static-pages/header.html" flush="true" />

While Server-Side Includes (SSI) and includes perform the same tasks, do not use SSI taglets in your JSPs. JRun no longer supports SSIs.

Not flushing output

In previous versions of JRun (and any servlet engine that adhered to the earlier specifications), you were required to flush the buffer output after an include action. The required flush attribute of the include action had to be set to true. In JRun 4, the attribute defaults to false and is optional. By setting the attribute to false, you can delay the flushing of the output buffer. Depending on your page size, this can improve the performance of your JSPs.

The following code line shows setting the flush attribute to false in an include action:

<jsp:include page="myadditionalpage.jsp" flush="false" /> 

Using the setProperty shortcut

JavaBeans store state information or other data used by JSPs. Processing form variables and storing each of the input fields as a bean property can be tedious, difficult to update, and prone to errors.

The following is a typical setProperty tag that sets the form field to a JavaBean property:

<jsp:setProperty name="myBean" property="first_name" value="<%= request.getParameter("first_name") %>" />

JSPs provide a shortcut that lets you set all the bean properties with one tag.

Set property attribute to * so that the jsp:setProperty tag iterates over all the request parameters and matches parameter names and value type to bean property names and types. Each matched property is set to the value of the matching parameter. You do not specify the value parameter in the setProperty tag.

The following is an example of using the property wildcard:

<jsp:setProperty name="myBean" property="*" />

If you set the parameter value to an empty string (""), the corresponding property is not modified. If the request parameter does not have a corresponding bean property, it is ignored.

Caching static data in jspInit

JRun calls the jspInit method once when a client first requests the JSP. It is only called again if the JSP source code changes or if you restart the JRun server. The jspInit method is the equivalent of a servlet's init method.

You can override the jspInit method of a JSP and store static data in it. A common example is constructing and initializing a database connection pool. Other tasks can also be handled in the jspInit method, such as retrieving application-scoped initialization parameters.

The following code sample shows a JSP page that gets an initialization parameter in the jspInit method and later uses it in the body:

<%!
 String email;
 public void jspInit() {
  System.out.println("in jspInit()");
  javax.servlet.ServletConfig servletConfig = getServletConfig();
  email = servletConfig.getServletContext().getInitParameter("email");
}
%>
<HTML><BODY>
Email addy is: <%= email %>
</BODY></HTML>

You define the initialization parameter in the context-param block of the web.xml file, as shown in the following example:

<web-app>
...
<context-param>
 <param-name>email</param-name>
 <param-value>webmaster@macromedia.com</param-value>
</context-param>
...
</web-app>

Using application-scoped beans for caching

Setting the scope of a bean to application indicates to JRun that there should only be one instance of the bean for the current application.

For example, if you select a list of states and their abbreviations from a database and store the results as properties in an application-scoped bean, you are not required to query the database every time you want to look up the full state name.

As a result, JRun only executes one database query until you restart the server. Any JSP that has access to the bean can now get at the properties of the bean, as shown in the following example:

<jsp:usebean id="statelist" class="jrunsamples.optimize.StateList" scope="application" />
<jsp:setProperty name="statelist" property="*" />

To access a state that is one of the bean's properties, use the following line:

<jsp:getProperty name="statelist" property="MA" />

You can also change the scope of a bean to session, page, or request. If you set a bean's scope to session, you must not override sessions=true in the page directive.

* iWiz´Ô¿¡ ÀÇÇØ¼­ °Ô½Ã¹° À̵¿µÇ¾ú½À´Ï´Ù (2010-02-03 16:57)



62   mod_throttle ¸ðµâÀ» ÀÌ¿ëÇÑ »ç¿ëÀÚ Æ®·¡ÇÈ Á¦¾î  iWiz 2006/06/22 9063 0
61   Tomcat-Apache using JK2 connector  iWiz 2004/03/21 7799 41
60   RedHat 9.0¿¡¼­ÀÇ JRun JSP ÄÄÆÄÀÏ·¯ÀÇ ¹®Á¦Á¡  iWiz 2004/01/04 5553 50
59   RedHat 9.0¿¡¼­ÀÇ JRun-Apache Ä¿³ØÅÍÀÇ ¹®Á¦Á¡  iWiz 2004/01/04 5187 48
58   JRun 4.0ÀÇ Æ©´× °ü·Ã ¿É¼Ç  iWiz 2004/01/04 5945 68
57   JRun 4.0ÀÇ Activity ¸ð´ÏÅ͸µ ¹æ¹ý  iWiz 2004/01/04 4921 57
56   JRun4.0: DataSource Ä¿³Ø¼ÇÇ® °ü·Ã ¿É¼Ç [4]  iWiz 2004/01/04 6664 46
55   JRun¿¡¼­ JSP ÄÄÆÄÀϽà java ÆÄÀÏ »ý¼ºÇÏ±â  iWiz 2004/01/04 8068 63
54   JRunÀÇ ½ÇÁ¦ ¼­ºñ½º ¿î¿µ½Ã °í·Á»çÇ×  iWiz 2004/01/04 6373 44
53   ¼öÁ¤µÈ ÀÎÅÍ³Ý ÀͽºÇ÷η¯¿¡¼­ »óÈ£ÀÛ¿ë ActiveX ÄÁÆ®·Ñ Ȱ¼ºÈ­ °¡ÀÌµå  iWiz 2006/03/03 8457 4
52   HTML Ư¼ö±âÈ£ ¿£ÅÍÆ¼(Entity) Å×À̺í [2]  iWiz 2006/03/03 14183 2
51   À¥»çÀÌÆ®ÀÇ »õ·Î¿î Çõ¸í Ajax [13]  iWiz 2005/11/22 5870 6
50   MSN ¸Þ½ÅÀú Ä£±¸ ÀÚµ¿µî·Ï ½ºÅ©¸³Æ®  iWiz 2004/10/12 6192 35
49   JavaScript MD5 ÇØ½¬ »ý¼º ÇÔ¼ö  iWiz 2004/01/07 9080 35
48   JavaScript·Î ¸¸µç Áø¹ýº¯È¯ ¹× º¸¼ö°è»ê±â [4]  iWiz 2004/01/04 160610 51

1 [2][3][4][5]
 

Copyright 1999-2023 Zeroboard / skin by zero
iWiz ShareBase, ¨ÏCopyleft by iWiz.  For more information contact .
º» À¥»çÀÌÆ®¿¡ °Ô½ÃµÈ À̸ÞÀÏ ÁÖ¼Ò°¡ ÀüÀÚ¿ìÆí ¼öÁý ÇÁ·Î±×·¥À̳ª ±× ¹ÛÀÇ ±â¼úÀû ÀåÄ¡¸¦ ÀÌ¿ëÇÏ¿© ¹«´ÜÀ¸·Î ¼öÁýµÇ´Â °ÍÀ» °ÅºÎÇϸç, À̸¦ À§¹Ý½Ã¿¡´Â Á¤º¸Åë½Å¸Á¹ý¿¡ ÀÇÇØ Çü»çó¹úµÊÀ» À¯³äÇϽñ⠹ٶø´Ï´Ù. [°Ô½ÃÀÏ 2004. 1. 31]