Servlet instance
In a servlet code, I have only one Servlet class(namely NewServlet).
When this page is accessed by different clients, will only one instance be created or multiple instance be created ??
Normally a servlet container will only create a single instance of a servlet. Unless you do something silly like declaring it to implement SingleThreadModel, that is. Why do you ask? Normally you should just make the servlet stateless and be done with it.
Similar Messages
-
Restricting Thread Pool for Servlet instances
I am using WebLogic5.1.0 version wherein I am registering a Servlet which
would be called by all the clients connecting
to my aplication. The servlet's service methods is taking some time to
execute. Since the servlet is following a SingleThreadModel, when there are
a large number of Clients connected, the number instances of Servlets
created are very high and the number of thread in the Application Server
process becomes very high affecting the performance of the other
applications.
Is it possible to restrict the number of instances of the servlets that get
created in the Application server ?
What are the setting required to achieve this ?
SandeepHi.
I'm not aware of a property setting that allows you to restrict the number of
servlet instances in WLS for the SingleThreadModel. The number of execute
threads is fixed - it does not grow depending on load. You can set this value
in the weblogic.properties file by setting weblogic.system.executeThreadCount.
This value is 15 by default.
It does sound like you are reaching the max capability of your
server/hardware. You should try tuning WLS.
Here are a couple of suggestions:
1. Try adjusting the executeThreadCount value to a higher value. Start by
setting it to 30 - see if that makes any difference.
2. Check out the following tuning guide:
http://www.weblogic.com/docs51/admindocs/tuning.html
3. Here is a list of admin properties that might aid in tuning:
http://www.weblogic.com/docs51/adminhelp/AdminPropertyHelp.html
4. If you are still having problems you might do better by posting this issue
to the performance newsgroup.
Regards,
Michael
Sandeep Rajpathak wrote:
I am using WebLogic5.1.0 version wherein I am registering a Servlet which
would be called by all the clients connecting
to my aplication. The servlet's service methods is taking some time to
execute. Since the servlet is following a SingleThreadModel, when there are
a large number of Clients connected, the number instances of Servlets
created are very high and the number of thread in the Application Server
process becomes very high affecting the performance of the other
applications.
Is it possible to restrict the number of instances of the servlets that get
created in the Application server ?
What are the setting required to achieve this ?
Sandeep--
Michael Young
Developer Relations Engineer
BEA Support -
Error allocating a servlet instance
i have a problem with the migration de aplication
the aplication it�s mountage in HP with Unix, with containner iPlanet, with data bases SyBASE; and migrated in mac os x with data bases in MySQL, container TomCat;
show the next error:
javax.servlet.ServletException: Error allocating a servlet instance
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:625)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:163)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:144)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2358)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:133)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:118)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:116)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:127)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:152)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:552)
root cause
java.lang.NoClassDefFoundError: ServletVerifyPsswd (wrong name: SCI/ServletVerifyPsswd)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:539)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1649)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:931)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1373)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1252)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:838)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:621)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:163)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:144)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2358)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:133)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:118)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:116)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:127)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:152)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:552)
configuration of the archive server.xml
<Context path="/sci" docBase="sci"
debug="5" reloadable="true" crossContext="true">
<Logger className="org.apache.catalina.logger.FileLogger"
prefix="localhost_sci_log." suffix=".txt"
timestamp="true"/>
<Resource name="jdbc/dbSCI"
auth="Container"
type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/dbSCI">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
<!-- Maximum number of dB connections in pool. Make sure you
configure your mysqld max_connections large enough to handle
all of your db connections. Set to 0 for no limit.
-->
<parameter>
<name>maxActive</name>
<value>100</value>
</parameter>
<!-- Maximum number of idle dB connections to retain in pool.
Set to 0 for no limit.
-->
<parameter>
<name>maxIdle</name>
<value>30</value>
</parameter>
<!-- Maximum time to wait for a dB connection to become available
in ms, in this example 10 seconds. An Exception is thrown if
this timeout is exceeded. Set to -1 to wait indefinitely.
-->
<parameter>
<name>maxWait</name>
<value>10000</value>
</parameter>
<!-- MySQL dB username and password for dB connections -->
<parameter>
<name>username</name>
<value>usersif</value>
</parameter>
<parameter>
<name>password</name>
<value>sifsci</value>
</parameter>
<!-- Class name for mm.mysql JDBC driver -->
<parameter>
<name>driverClassName</name>
<value>com.mysql.jdbc.Driver</value>
</parameter>
<!-- The JDBC connection url for connecting to your MySQL dB.
The autoReconnect=true argument to the url makes sure that the
mm.mysql JDBC Driver will automatically reconnect if mysqld closed the
connection. mysqld by default closes idle connections after 8 hours.
-->
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost:3306/bdsif?autoReconnect=true</value>
</parameter>
</ResourceParams>
</Context>
and the archive web.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<description>Sistema de Consultas Integrales</description>
<display-name>Sistema de Consultas Integrales</display-name>
<servlet>
<servlet-name>Connect</servlet-name>
<servlet-class>Connect</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Connect</servlet-name>
<url-pattern>/servlet/Connect</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>ServletAcuOperacionSIF</servlet-name>
<servlet-class>ServletAcuOperacionSIFeClase</servlet-class>
</servlet>
mapping the servlet
<resource-ref>
<description>DB Coneccion</description>
<res-ref-name>jdbc/dbSCI</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>package SCI;
import javax.servlet.http.*;
import javax.servlet.*;
import java.sql.*;
import java.io.*;
import java.util.*;
import java.math.*;
import java.text.*;
public class ServletAcumuladoOp extends HttpServlet{
private ServletOutputStream out = null;
private ResultSet resultado = null;
private Statement query = null;
private String tv;
private String liq;
public ServletAcumuladoOp(){
super();
public void init(){
//System.out.println("Inicie el servicio del ServletAcumuladoOp...");
try{
Class.forName("com.mysql.jdbc.Driver");
//System.out.println("Carge el Driver Sybase...");
}catch(java.lang.ClassNotFoundException e){
System.out.println("Imposible cargar la clase : "+e.getMessage()+" ,,,Verifique la Ruta");
public boolean datosOk(HttpServletRequest req){
//System.out.println(req.getRemoteUser());
Enumeration e = req.getParameterNames();
Hashtable ht = new Hashtable();
while (e.hasMoreElements()) {
String cad= (String) e.nextElement();
ht.put(cad," ");
// System.out.println(cad);
if ( ht.containsKey("TV_AS") && ht.containsKey("Liq") ){
tv = "";
liq = "";
liq = req.getParameter("Liq");
tv = req.getParameter("TV_AS");
}else{
return false;
return true;
protected synchronized void doPost(HttpServletRequest req, HttpServletResponse res)
throws IOException, ServletException{
res.setContentType("text/html");
out = res.getOutputStream();
out.println("<html>\n<head>\n<title>Acumulado de operaciones</title>\n</head>\n<body background='../../../../../SCI/GRA/fondo.jpg'><center>");
if (datosOk(req)){
out.println("<TABLE BORDER=0 width=740 cellspacing=0 cellpadding=0>\n");
out.println("<tr>\n");
out.println("<td valign='top'><font face='Verdana,Arial' size=2 color='black'><b>");
out.println("Acumulado de operaciones");
out.println("</b></TD>\n");
out.println("<td ALIGN=RIGHT valign='top'><font face='Verdana,Arial' size=1 color='black'>"+getFechaLocal()+"</FONT></TD>\n");
out.println("</tr>\n");
out.println("<tr>\n");
out.println("<TD colspan=2 align='left' valign='top'>\n");
out.println("<font face='Verdana,Arial' size=2 color='black'>\n");
if (tv.equals("") || tv.equals("*"))
out.println("Tipo de valor: <B>Todos</B>");
else
out.println("Tipo de valor: <B>"+tv+"</B>");
if (liq.equals("") || liq.equals("*"))
out.println(", Liquidación: <B>Todas</B>");
else
out.println(", Liquidación: <B>"+liq+"</B>");
out.println("</font></TD>\n");
out.println("</TR>\n");
out.println("</table>\n");
out.println("<br>\n");
if (getConsulta())
out.println("</TABLE>\n<HR color=Black width=740>\n</center></BODY>\n</HTML>");
else
out.println("<br><center><font face='Verdana,Arial' size=4 color=Red>No existen datos para este rango de fechas</font></center>\n</BODY>\n</HTML>");
}else{
out.println("<BR><font face='Verdana,Arial' size=4 color=Red> Se ha producido un error interno... Los par�metros de este Servlet son incorrectos \n</font>\n</BODY>\n</HTML>");
out.close();
public void setHead()throws IOException{
out.println("<table border=0 width=740 height=30 cellspacing=0 cellpadding=0>\n<tr>\n");
out.println("<td width=60 align=center ><font face='Verdana,Arial' size=-1><b>Inst</td>\n");
out.println("<td width=60 align=center ><font face='Verdana,Arial' size=-1><b>Emisora</td>\n");
out.println("<td width=40 align=center><font face='Verdana,Arial' size=-1><b>Liq</td>\n");
out.println("<td width=50 align=center><font face='Verdana,Arial' size=-1><b>Oper</td>\n");
out.println("<td width=70 align=center><font face='Verdana,Arial' size=-1><b>N Series</td>\n");
out.println("<td width=70 align=center><font face='Verdana,Arial' size=-1><b>N Oper</td>\n");
out.println("<td width=150 align=center><font face='Verdana,Arial' size=-1><b>Vol�men</td>\n");
out.println("<td width=150 align=center><font face='Verdana,Arial' size=-1><b>Importe</td>\n");
out.println("<td width=90 align=center><font face='Verdana,Arial' size=-1><b>% Part.</td>\n");
out.println("</tr>");
public boolean getConsulta() throws IOException{
Connection conexion = getConexion();
try{
DecimalFormat df = new DecimalFormat("###,###,###,###,###.00");
String cadTV = "";
String cadLiq = "";
int cont = 0;
double operaciones_total = 0;
double volumen_total = 0;
double importe_total = 0;
double operaciones_subtot = 0;
double volumen_subtot = 0;
double importe_subtot = 0;
double suma_total_importe = 0;
double porcentaje = 0;
boolean ok = false;
int cent = 0;
boolean bandera = true;
int col = 0;
String color = "";
//Determina si ya cerr� el mercado
query=conexion.createStatement();
String sql = "select ctr_estado from ctrlre";
resultado=query.executeQuery(sql);
while (resultado.next())
cadTV = resultado.getString(1);
out.println("<table border=0 width=740 height=30 cellspacing=0 cellpadding=0 >");
out.println("<TR>");
out.println("<TD bgcolor='#FFFFBB' align=right><FONT face='Verdana,Arial'><b>");
if ( cadTV.equals("NO") )
out.println("DEFINITIVO</b></FONT> </TD> </TR> </table>\n");
else
out.println("PRELIMINAR</b></FONT> </TD> </TR> </table>\n");
out.println("<BR>");
cadTV="";
sql = getSql();
query = conexion.createStatement();
resultado = query.executeQuery(sql);
//out.println(sql);
while(resultado.next()){
if (bandera){
setHead();
bandera = false;
String tvalor = resultado.getString(1); //thp_tipo_valor
String emisora = resultado.getString(2); //thp_emisora
String liquidacion = resultado.getString(3); //thp_liquidacion
String toperacion = resultado.getString(4); //thp_tipo_operacion
int series = resultado.getInt(5); //series
int operaciones = resultado.getInt(6); //operaciones
double volumen = resultado.getDouble(7);; //thp_volumen
double importe = resultado.getDouble(8);; //thp_importe
// Salida al browser
if (cont == 0){
cadTV = tvalor.trim();
cadLiq = liquidacion.trim();
suma_total_importe = getTotalImporte(tvalor, liquidacion);
if (col == 1){
color = "#E1E1E1";
col = -1;
if (col == 0)
color = "#FFFFFF";
col++;
if ( (!cadTV.equals(tvalor.trim()) || !cadLiq.equals(liquidacion.trim()) )&& cont != 0){
setSubTotal(cadLiq, operaciones_subtot, volumen_subtot, importe_subtot, df);
suma_total_importe = getTotalImporte(tvalor, liquidacion);
// Agrega a sumas totales
operaciones_total = operaciones_total + operaciones_subtot;
volumen_total = volumen_total + volumen_subtot;
importe_total = importe_total + importe_subtot;
operaciones_subtot = 0;
volumen_subtot = 0;
importe_subtot = 0;
cadTV = tvalor.trim();
cadLiq = liquidacion.trim();
cont=0;
out.flush();
operaciones_subtot = operaciones_subtot + operaciones;
volumen_subtot = volumen_subtot + volumen;
importe_subtot = importe_subtot + importe;
if (suma_total_importe == 0)
porcentaje = 0;
else
porcentaje = ( importe * 100 ) / suma_total_importe;
setRow(color,
" "+tvalor,
" "+emisora,
" "+liquidacion,
" "+toperacion,
" "+series,
" "+operaciones,
" "+df.format(volumen),
" "+df.format(importe),
" "+getScala(porcentaje,2));
cont++;
cent++;
conexion.close();
if (cent==0){ // No hubo registros
return false;
if (cont!=0){
setSubTotal(cadLiq, operaciones_subtot, volumen_subtot, importe_subtot, df);
// Agrega a sumas totales
operaciones_total = operaciones_total + operaciones_subtot;
volumen_total = volumen_total + volumen_subtot;
importe_total = importe_total + importe_subtot;
setTotal(operaciones_total, volumen_total, importe_total, df);
}catch(SQLException e){
System.out.println("Codigo de Error :"+e.getErrorCode());
System.out.println("Descripci�n del error :"+e.getMessage());
System.out.println("Estado del SQL :"+e.getSQLState());
return true;
public String getSql(){
String sql1="select thp_tipo_valor, thp_emisora, thp_liquidacion, thp_tipo_operacion, "+
"count(distinct(thp_emision)), count(thp_folio), sum(thp_volumen), sum(thp_importe) "+
"from thecprod "+
"where ( thp_tipo_valor = '"+tv+"' or '"+tv+"'='*') and "+
" ( thp_liquidacion = '"+liq+"' or '"+liq+"'='*') "+
"group by thp_tipo_valor, thp_emisora, thp_liquidacion, thp_tipo_operacion";
return sql1;
public void setRow(String a1,String a2,String a3,String a4,String a5,String a6,String a7,String a8,
String a9, String a10) throws IOException{
out.println("<tr bgcolor='"+a1+"'"+" align=center bordercolor='"+a1+"' bordercolorlight='"+a1+"' bordercolordark='"+a1+"'>\n");
out.println("<td width=60 align=center><font face='Verdana,Arial' size=-1>"+a2+"</td>\n");
out.println("<td width=60 align=center><font face='Verdana,Arial' size=-1>"+a3+"</td>\n");
out.println("<td width=40 align=center><font face='Verdana,Arial' size=-1>"+a4+"</td>\n");
out.println("<td width=50 align=center><font face='Verdana,Arial' size=-1>"+a5+"</td>\n");
out.println("<td width=70 align=center><font face='Verdana,Arial' size=-1>"+a6+"</td>\n");
out.println("<td width=70 align=center><font face='Verdana,Arial' size=-1>"+a7+"</td>\n");
out.println("<td width=150 align=right><font face='Verdana,Arial' size=-1>"+a8+"</td>\n");
out.println("<td width=150 align=right><font face='Verdana,Arial' size=-1>"+a9+"</td>\n");
out.println("<td width=90 align=right><font face='Verdana,Arial' size=-1>"+a10+"%</td>\n");
out.println("</tr>\n");
public void setSubTotal(String liquidacion, double operaciones_sub, double volumen_sub, double importe_sub, DecimalFormat df)throws IOException {
out.println("<tr>\n");
out.println("<td width=60 align=center bgcolor=#FFFFFF><font face='Verdana,Arial' size=-1> </td>\n");
out.println("<td width=60 align=center bgcolor=#FFFFFF><font face='Verdana,Arial' size=-1> </td>\n");
out.println("<td width=40 align=center bgcolor=#ffffbb><font face='Verdana,Arial' size=-1>"+liquidacion+"</td>\n");
out.println("<td width=50 align=center bgcolor=#ffffbb><font face='Verdana,Arial' size=-1>Total</td>\n");
out.println("<td width=70 align=center bgcolor=#ffffbb><font face='Verdana,Arial' size=-1> </td>\n");
out.println("<td width=70 align=center bgcolor=#ffffbb><font face='Verdana,Arial' size=-1>"+getScala(operaciones_sub,0)+"</td>\n");
out.println("<td width=150 align=right bgcolor=#ffffbb><font face='Verdana,Arial' size=-1>"+df.format(volumen_sub)+"</td>\n");
out.println("<td width=150 align=right bgcolor=#ffffbb><font face='Verdana,Arial' size=-1>"+df.format(importe_sub)+"</td>\n");
out.println("<td width=90 align=right bgcolor=#ffffbb><font face='Verdana,Arial' size=-1>100.00%</td>\n");
out.println("</tr>\n");
public void setTotal(double operaciones_total, double volumen_total, double importe_total, DecimalFormat df)throws IOException {
out.println("<tr>\n");
out.println("<td width=60 align=center bgcolor=#FFFFFF><font face='Verdana,Arial' size=-1> </td>\n");
out.println("<td width=60 align=center bgcolor=#FFFFFF><font face='Verdana,Arial' size=-1> </td>\n");
out.println("<td width=40 align=center bgcolor=#FFFFFF><font face='Verdana,Arial' size=-1> </td>\n");
out.println("<td width=50 align=center bgcolor=#FFFFFF><font face='Verdana,Arial' size=-1> </td>\n");
out.println("<td width=70 align=center bgcolor=#FFFFFF><font face='Verdana,Arial' size=-1> </td>\n");
out.println("<td width=70 align=center bgcolor=#b5cffb><font face='Verdana,Arial' size=-1>"+getScala(operaciones_total,0)+"</td>\n");
out.println("<td width=150 align=right bgcolor=#b5cffb><font face='Verdana,Arial' size=-1><b>"+df.format(volumen_total)+"</td>\n");
out.println("<td width=150 align=right bgcolor=#b5cffb><font face='Verdana,Arial' size=-1><b>"+df.format(importe_total)+"</td>\n");
out.println("<td width=90 align=right bgcolor=#b5cffb><font face='Verdana,Arial' size=-1><b> </td>\n");
out.println("</tr>\n");
public String getScala(double val, int uno){
BigDecimal bd = new BigDecimal(val);
return " "+bd.setScale(uno,5);
protected synchronized double getTotalImporte(String tipovalor, String liquidacion){
double total = 0;
try{
Connection conexion1 = getConexion();
Statement q = conexion1.createStatement();
String sql ="";
sql = "select sum(thp_importe) from thecprod where thp_tipo_valor = '"+tipovalor+"' and thp_liquidacion = '"+liquidacion+"'";
ResultSet res = q.executeQuery(sql);
while(res.next()){
total = res.getDouble(1);
res.close();
conexion1.close();
}catch(SQLException e){
System.out.println("Codigo de Error :"+e.getErrorCode());
System.out.println("Descripci�n del error :"+e.getMessage());
System.out.println("Estado del SQL :"+e.getSQLState());
return total;
public Connection getConexion(){
String url ="jdbc:mysql//localhost:3306/bdsif";
Connection conexion = null;
try{
conexion = DriverManager.getConnection(url, "usersif", "password");
}catch(SQLException e){
System.out.println("Codigo de Error :"+e.getErrorCode());
System.out.println("Descripci�n del error :"+e.getMessage());
System.out.println("Estado del SQL :"+e.getSQLState());
return conexion;
public String getFechaLocal(){
java.util.Date today;
String output;
java.text.SimpleDateFormat formatter;
formatter = new java.text.SimpleDateFormat("EEEEEEEEE dd 'de' MMMMMMMMMM 'del' yyyy", new Locale("es", "Spanish"));
today = new java.util.Date();
return " "+formatter.format(today);
public void destroy(){
// System.out.println("Destrui el ServletAcumuladoOp...");
} -
Hi
I am have a web application that does a lot of processing. when 2 users submit the form.. i noticed that one instance of the servlet is running and the other request waits for some time for
processor and just dies off.. Servlets are suppose to be thread safe and 'n' number of intances can be created . why only one
instance running at a given time.. My servlet is not a single instance servlet and i have not placed an restrictions of that sort..
can anyone help me with this ??
rgds
satishI have written the processing part in dopost method.. which takes a few seconds to finish for each instance (creatting a huge array of objects ). Then i keep the reference of this in session. While the objects are being generated, if i send another request the first servlets dies and the second one proceeds , sometimes second one dies off after waiting for something..
yes i am testing by 2 users from 2 different machines.its not the connection problem.. the systems.outs show that both the servlet instances are running at one point of time then suddenly one dies.. i have allocated 1000m to tomcat... so memory is not a problem i suppose..
Any helping tips ?
rgds
satish -
Where is a Servlet instance stored in Tomcat?
Hi,
We know that servlet container generates ONLY ONE servlet instance which will handle all the client requests for the servlet. This makes big inconvenionce in debug phase using Tomcat server. Unless restarting the server, you will not be able to see the changes you made in the servlet class.
My question is where the servlet instance is stored in Tomcat. I think it should be in [TOMCAT_HOME]/work/ directory but actually not. My approach is deleting the instance before sending request to the servlet. In this way, servlet container will generate an instance of new version of the servlet class.
Is there any other way to work around that?
Thanks,We know that servlet container generates ONLY ONE
servlet instance which will handle all the client
requests for the servlet. My Tomcat instance will pool servlet instances. It might look like only one instance to you, but that doesn't mean that Tomcat does it that way.
This makes big inconvenionce in debug phase using Tomcat server. This makes no sense to me. Are you talking about load testing?
Unless restarting the server, you will not be able to see the changes you made in the servlet class.This has nothing to do with debugging. And Tomcat has hot deployment now if you do it correctly with WAR files.
My question is where the servlet instance is stored in Tomcat. I think it should be in
[TOMCAT_HOME]/work/ directory but actually not. My approach is deleting the instance before sending
request to the servlet. In this way, servlet container will generate an instance of new version of the
servlet class.Sounds like you don't know how to deploy to Tomcat properly. Servlet .class files are stored where you put them: in the WEB-INF/classes directory for your Web app, in a JAR in the WEB-INF/lib directory for your Web app. These are either in the TOMCAT_HOME/webapps context directory that you create or, better yet, in the WAR file that you deploy to TOMCAT_HOME/webapps.
The /work directory that you refer to is where Tomcat puts generated Java code for JSPs.
Is there any other way to work around that?There's no way to change it, and there's no reason that I can think of to explain why you'd want to. What is the real problem here? -
HELP!!!! -- Error allocating a servlet instance
Please help me...
The deathline for my schoolproject is getting close!!!
- 2 weeks ago everything worked fine
- now i wanted to start at making the last changes...
but...the only thing a get is this...
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Error allocating a servlet instance
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:670)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:432)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:386)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:534)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:530)
at java.lang.Thread.run(Thread.java:536)
root cause
java.lang.NoClassDefFoundError: javax/servlet/http/HttpServlet
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:502)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:250)
at java.net.URLClassLoader.access$100(URLClassLoader.java:54)
at java.net.URLClassLoader$1.run(URLClassLoader.java:193)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:186)
at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
at java.lang.ClassLoader.loadClass(ClassLoader.java:292)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:265)
at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1340)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1274)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:884)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:666)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:432)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:386)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:534)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:530)
at java.lang.Thread.run(Thread.java:536)The actual bizare thing in all this is that everything worked fine 2 weeks ago and that i touched nothing in the meanwhile...
Important to note is also that the examples of tomcat still work fine so that i know that servlet.jar is at his place and in fact still being used correctly, at least in those examples.
What the servlet itself consernes, by putting a println-statement at the beginning of the init-method i can conclude that he doesn't seems to be able to reach the servlet at all. (compilation of all my files works still without any problems)
Could it be possible that my problem has something to do with the web.xml file? Ok, he worked alright...but maybe something isn't quite as it should be...
Thx for the responses!!!
Maybe you guys can help me further with this information...I at least hope so!
greetings
steven -
What if i give -1 as a Servlet instance in pool in web.xml
What if i give -1 as a no of Servlet instance, in pool, in web.xml
Try it and them get back to us and let us know if it works.
-
SingleThreadModel and amount of servlet instances ??
Hi !
Is there anybody who knows how to determine amount of servlet instances in
wl5.1 if the servlet is implemented in SingleThreadModel ?
P.asi
Yup, I remember somebody mentioned that initial size is hardcoded to 5 and
max size to 20.
Robert Patrick <[email protected]> wrote:
> I am not sure if a recent Service Pack has changed this or not but the
> original implementation in WLS 5.x was that the SingleThreadModel always used
> a fixed number of servlet instances (5, I think...).
> Pasi Lukkarinen wrote:
>> Hi !
>>
>> Is there anybody who knows how to determine amount of servlet instances in
>> wl5.1 if the servlet is implemented in SingleThreadModel ?
>>
>> P.asi
Dimitri
-
How can we differentiate between Servlet instances and threads.
Actuaaly i want to know how a servlet handles multiple client requests at the same time.
what i know is like:::
a client sends a request to the server.
A new thread is generated which will call the instance of the serlvlet on the server for processing..
Is this flow is correct???
am bit confused between threads and instances.
Please help!!!!If you make that your servlets implement the
SingleThreadModel interface (definition below), then
you can configure Tomcat with the size of the pool. I
think that even you can have only one instance, but
this is not very advisable, unless you want your users
to wait...Thnx for reply, Do you know how I can tell Tomcat to start multiple instances or alway stick with single instance. I cannot find this.
"public interface SingleThreadModel
Ensures that servlets handle only one request at a
time. This interface has no methods. Yes I am aware of this.
If a servlet implements this interface, you are
guaranteed that no two threads will execute
concurrently in the servlet's service method. The
servlet container can make this guarantee by
synchronizing access to a single instance of the
servlet, or by maintaining a pool of servlet instances
and dispatching each new request to a free servlet.
This interface does not prevent synchronization
problems that result from servlets accessing shared
resources such as static class variables or classes
outside the scope of the servlet."If only one user can access the servlet using this interface then why would you want syncrhonization??? There shouldn't be synchornization issues with a servlet that implements SingleThreadModel right?? -
OC4J / more servlet instances on startup
Runninng SingleThreadModel-Servlet on OC4J want to initialize 10 servlet-instances on startup of my container. Can somebody tell me how should I configure OC4J to get it ???
best regards
StanI've solved the said problem. I need to add load-on-startup to <default-web-app application="default" name="defaultWebApp" root="/j2ee" load-on-startup="true"/>.
James Thanks for sending the solution James.
-steve- -
Regarding servlets instance and client
Hi
Suppose 5 client programs are calling one servlets at a time.
Then how many instance will create 1 or 5?
if 1 then how 5 requests will be be processedPlease read "SRV.2.2 Number of Instances" in the Servlet specification.
-
This might be a dumb question, but I'll ask it anyway...
I have methods in my servlet to handle registration, specifically creating address, customer and order objects.
All the information needed for creating my objects is coming from the registration form.
Right now if I were to call the createAddress() method, I have to pass the request object.... createAddress(request);
Would it be "thread safe" to make an instance variable of the request and refer to it using getters/setters? Or would it be wiser (and best practice) to make instance variables for the request attributes (like firstName, lastName, etc.)? Or am I way off and shouldn't be doing any of the above?
Thanks for the help.GB_java_guy wrote:
To answer you question, I think it's different, from what I've read, because request attributes are supposed to be thread safe and I'd be using the request attributes instead of the request object.You said something about "making instance variables for the request attributes." I don't know what you mean by that, but if it's instance variable in the servlet class, don't do it.
I have no clue what you mean by "request attirbutes intead of request object."
So are you saying I should just use the request object and pass that to my methods instead? In general, yes. In some cases you may want to pass individual pieces of it--e.g. if there's a method that doesn't need to know or care about the fact that you're operating in a servlet context, and just needs a couple values to do its job. -
Servlet Instance Variable scope
Just want to clarify my understanding of instance variables in regards to Servlets.
public class TestServlet extends HttpServlet
public String instVariable = "";
public void processRequest(HttpServletRequest request, HttpServletResponse response)
instVariable = request.getParameter("param");
response.sendRedirect( instVariable ) ;
}If two users both enter the processRequest logic at the same time, is it possible that they will both get the same
result? My understanding of this was that if they each execute the first line, then each execute the second
line, each user would be redirected to the same instVariable that was set by the second request.
What would be the easiest way to stop this from happening? syncronized? ThreadSafe?
I just want a simple clarification.
Thanks for the insight.If two users both enter the processRequest logic at
the same time, is it possible that they will both get
the same
result? My understanding of this was that if they
each execute the first line, then each execute the
second
line, each user would be redirected to the same
instVariable that was set by the second request. Yes, it is possible, since there is only one instVariable.
What would be the easiest way to stop this from
happening? syncronized? ThreadSafe? The easiest way to avoid that is to simply not use an instance variable. Use a local variable, declared within your processRequest method. Each thread (i.e. each user of the servlet) has its own set of local variables. -
Servlet instances being destroyed?
Hi,
I converted my web app from 5.1 to 6.0 and tried hitting a jsp page. All of
a sudden, I get the following:
<[WebAppServletContext kiko] *.html: destroy>
####<Nov 7, 2000 4:44:37 PM PST> <Info> <HTTP> <> <myserver> <main> <guest>
<> <101142>
<Error unregistering servlet runtime
mydomain:Name=myserver_kiko_kiko_weblogic.servlet.FileServlet_170,Location=m
yserver,Type=ServletRuntime>
javax.management.InstanceNotFoundException:
mydomain:Name=myserver_kiko_kiko_weblogic.servlet.FileServlet_170,Location=m
yserver,Type=ServletRuntime
at
javax.management.MBeanServer.unregisterMBean(MBeanServer.java:866)
at
weblogic.management.internal.RemoteMBeanServerImpl.unregisterMBean(RemoteMBe
anServerImpl.java:106)
at
weblogic.management.runtime.RuntimeMBeanDelegate.unregister(RuntimeMBeanDele
gate.java:96)
at
weblogic.servlet.internal.ServletStubImpl.destroyServlet(ServletStubImpl.jav
a:442)
at
weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.jav
a:526)
at
weblogic.servlet.internal.ServletStubImpl.checkForReload(ServletStubImpl.jav
a:464)
at
weblogic.servlet.internal.ServletStubImpl.getServlet(ServletStubImpl.java:29
8)
at
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
:201)
at
weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletCo
ntext.java:1114)
at
weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java
:1388)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:133)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:116)
--------------- nested within: ------------------
weblogic.management.ManagementException: - with nested exception:
[javax.management.InstanceNotFoundException:
mydomain:Name=myserver_kiko_kiko_weblogic.servlet.FileServlet_170,Location=m
yserver,Type=ServletRuntime]
at
weblogic.management.runtime.RuntimeMBeanDelegate.unregister(RuntimeMBeanDele
gate.java:98)
at
weblogic.servlet.internal.ServletStubImpl.destroyServlet(ServletStubImpl.jav
a:442)
at
weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.jav
a:526)
at
weblogic.servlet.internal.ServletStubImpl.checkForReload(ServletStubImpl.jav
a:464)
at
weblogic.servlet.internal.ServletStubImpl.getServlet(ServletStubImpl.java:29
8)
at
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
:201)
at
weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletCo
ntext.java:1114)
at
weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java
:1388)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:133)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:116)
Why is the FileServlet instance being destroyed by WL?
Gene Chuang
Join Kiko.com!
I suspect that what is happening here is that when the jsp gets compiled, the
code that detects changes in the applications directory notices that the app
has changed and tries to reload it. This seems like a bug to me. I have
entered CR038194 to track this problem.
mark
Gene Chuang wrote:
> Hi,
>
> I converted my web app from 5.1 to 6.0 and tried hitting a jsp page. All of
> a sudden, I get the following:
>
> <[WebAppServletContext kiko] *.html: destroy>
> ####<Nov 7, 2000 4:44:37 PM PST> <Info> <HTTP> <> <myserver> <main> <guest>
> <> <101142>
> <Error unregistering servlet runtime
> mydomain:Name=myserver_kiko_kiko_weblogic.servlet.FileServlet_170,Location=m
> yserver,Type=ServletRuntime>
> javax.management.InstanceNotFoundException:
> mydomain:Name=myserver_kiko_kiko_weblogic.servlet.FileServlet_170,Location=m
> yserver,Type=ServletRuntime
> at
> javax.management.MBeanServer.unregisterMBean(MBeanServer.java:866)
> at
> weblogic.management.internal.RemoteMBeanServerImpl.unregisterMBean(RemoteMBe
> anServerImpl.java:106)
> at
> weblogic.management.runtime.RuntimeMBeanDelegate.unregister(RuntimeMBeanDele
> gate.java:96)
> at
> weblogic.servlet.internal.ServletStubImpl.destroyServlet(ServletStubImpl.jav
> a:442)
> at
> weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.jav
> a:526)
> at
> weblogic.servlet.internal.ServletStubImpl.checkForReload(ServletStubImpl.jav
> a:464)
> at
> weblogic.servlet.internal.ServletStubImpl.getServlet(ServletStubImpl.java:29
> 8)
> at
> weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
> :201)
> at
> weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletCo
> ntext.java:1114)
> at
> weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java
> :1388)
> at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:133)
> at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:116)
> --------------- nested within: ------------------
> weblogic.management.ManagementException: - with nested exception:
> [javax.management.InstanceNotFoundException:
> mydomain:Name=myserver_kiko_kiko_weblogic.servlet.FileServlet_170,Location=m
> yserver,Type=ServletRuntime]
> at
> weblogic.management.runtime.RuntimeMBeanDelegate.unregister(RuntimeMBeanDele
> gate.java:98)
> at
> weblogic.servlet.internal.ServletStubImpl.destroyServlet(ServletStubImpl.jav
> a:442)
> at
> weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.jav
> a:526)
> at
> weblogic.servlet.internal.ServletStubImpl.checkForReload(ServletStubImpl.jav
> a:464)
> at
> weblogic.servlet.internal.ServletStubImpl.getServlet(ServletStubImpl.java:29
> 8)
> at
> weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
> :201)
> at
> weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletCo
> ntext.java:1114)
> at
> weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java
> :1388)
> at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:133)
> at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:116)
>
> Why is the FileServlet instance being destroyed by WL?
>
> --
> Gene Chuang
> Join Kiko.com!
-
SSLSession instance in servlets
How can I get SSLSession instance or SSL session propereties inside servlets in OC4J?
money321 wrote:
Because in beginning I was not sure that Servlets instances are also actually threads.They are not not threads. Each call to doGet(), doPost() etc is called in a Thread and since there can be many simultaneous calls each having it's own thread a Servlet has to be thread safe.
My other question was specific to threads as I was trying to implement threads.Why?
>
But in this one I rather used servlets.
But apologies, as instance of servlet are also threads.As I said, they are not threads.
>
But still one last doubt.
Sabre if you could please clarify the same as well :How about you do some reading [http://java.sun.com/developer/onlineTraining/Servlets/Fundamentals/|http://java.sun.com/developer/onlineTraining/Servlets/Fundamentals/] and use Google.
>
in your option 2 and three I will have to pass request object to function fun().No. You will need access to the request object for 2 and the servlet context for 3. You need to pass something
If i am correct on this then is this too a better approach ?My preferred approach is 1 since it makes much of your code testable outside of a Servlet.
Maybe you are looking for
-
Adobe acrobat pro 9 instructions
I didn't get an instructions manual for adobe acrobat pro 9 so I don't know how to use it. I had adobe acrobat 5.. please anyone know of a way to get the electronic version of a manual.. and basic instructions on how to use this.. thanks
-
My late 2009/early 2010 (i forgot) macbook pro won't start up
Two days ago, I copied a lot of videos & photos into my macbook without checking the available hard drive left. I also had a problem with the trackpad that keeps forgetting my settings, so I searched for solutions online. I read somewhere that said t
-
Illustrator CS4 won't open any files since installing CS6
Every since I installed CS6, whenever I try to open files in Illustrator (all files, not just the new downsaved from CS6 files), the program goes into "Not Responding" and I can't do anything until I crash out. It also will not let me create new file
-
Please help me out with something simple.
I know this is simple probably to figure out but I really want to make sure that I do this correctly. So please if someone could tell me exactly how to get my ipod working. Do I need to re-install itunes if I had it on here for my old ipod? And when
-
P4N Diamond and Pentium D problem
Hi, Have just bought the P4N Diamond motherboard, and a Pentim D 830 processor. When switching on the status led shows four red lights. According to the manual this means that the processor is defective. Have taken the processor in and out many times