Java Servlet: Нұсқалар арасындағы айырмашылық

Уикипедия — ашық энциклопедиясынан алынған мәлімет
Навигацияға өту Іздеуге өту
Content deleted Content added
Өңдеу түйіні жоқ
Өңдеу түйіні жоқ
1-жол: 1-жол:
[[Image:JSPLife.png|thumb|600px|Сүретте JSP файлының бағдарламалық жасақтамадағы қызметі көрсетілген.]]
[[Image:JSPLife.png|thumb|600px|Сүретте JSP файлының бағдарламалық жасақтамадағы қызметі көрсетілген.]]
'''Servlet''' - компьютер [[сервер]]і мүмкіншіліктерін арттыруға арналып жазылған [[Java]] бағдарламалық тіліндегі [[класс]].
'''Servlet''' - компьютер [[сервер]]і мүмкіншіліктерін арттыруға арналып жазылған [[Java]] бағдарламалық тіліндегі [[класс]].

== Мысалы ==
<!--
The following example Servlet prints how many times its <code>service()</code> method was called.

Note that <code>HttpServlet</code> is a subclass of <code>GenericServlet</code>, an implementation of the <code>Servlet</code> interface.

The <code>service()</code> method of <code>HttpServlet</code> class dispatches requests to the methods <code>doGet()</code>, <code>doPost()</code>, <code>doPut()</code>, <code>doDelete()</code>, and so on; according to the HTTP request. In the example below method <code>service()</code> is overridden and does not distinguish which HTTP request method it serves.
-->

<source lang="java">
import java.io.IOException;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class ServletLifeCycleExample extends HttpServlet {
private int count;
@Override
public void init(ServletConfig config) throws ServletException {
super.init(config);
getServletContext().log("init() called");
count=0;
}
@Override
protected void service(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
getServletContext().log("service() called");
count++;
response.getWriter().write("Incrementing the count: Count = "+count);
}
@Override
public void destroy() {
getServletContext().log("destroy() called");
}
}
</source>


<!--
<!--

15:54, 2012 ж. қазанның 12 кезіндегі нұсқа

Сүретте JSP файлының бағдарламалық жасақтамадағы қызметі көрсетілген.

Servlet - компьютер сервері мүмкіншіліктерін арттыруға арналып жазылған Java бағдарламалық тіліндегі класс.

Мысалы

import java.io.IOException;
 
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
 
public class ServletLifeCycleExample extends HttpServlet {
 
    private int count;
 
    @Override
    public void init(ServletConfig config) throws ServletException {
        super.init(config);
        getServletContext().log("init() called");
        count=0;
    }
 
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        getServletContext().log("service() called");
        count++;
        response.getWriter().write("Incrementing the count: Count = "+count);
    }
 
    @Override
    public void destroy() {
        getServletContext().log("destroy() called");
    }	
 
}


Сілттемелер