Article View: comp.lang.java.programmer
Article #665S.O.S. Servlets, maiday maiday maiday
From: Juan Carlos
Date: Fri, 07 Aug 1998 00:00
Date: Fri, 07 Aug 1998 00:00
90 lines
3230 bytes
3230 bytes
Hello all,
firstly, thanks for read this message.
My problem is:
I have run ServletExec (very good), IIS 4.0 (cool but I also can use all
webservers), JDK1.1.6, JSDK 2.0, really works fine.
But, my problem are Cookies. In this API (jsdk2.0), don�t exits
"sun.servlet.http.Cookie;" , using this API don�t work Cookies.
I cannot use the "Cookie.saveCookie(response);"
What is the problem????
what�s happen ????
:-((
this is the source code:
-------------------- begin source ------------------
protected void doGet(HttpServletRequest req, HttpServletResponse
res) throws IOException
{
try
{
//Crear un cookie para controlar al cliente.
Cookie a = new
Cookie("firstServlet",String.valueOf(1111));
a.setPath("/");
a.setMaxAge(1 * 24 * 60 * 60);
a.setDomain(domain);
res.setHeader("Set-Cookie","firstServlet="+a.getValue()+";Domain="+a.getDomain()+";Path="+a.getPath());
res.addCookie(a);
ServletOutputStream out = res.getOutputStream(); //Get a
channel to the Web browser, so we can send output
res.setContentType("text/html"); // Required for HTTP
out.println("<HTML><HEAD><TITLE>CENTRO DE ENSE�ANZA
VIRTUAL</TITLE></HEAD>");
Cookie c[] = req.getCookies();
if ( c != null)
{
String key = String.valueOf (c[0].getValue());
out.println("Cookie: " + key + " " +
req.getParameter("userName") + " aceptado correctamente. numero de
cookies..." + c.length );
}
else
{
out.println("Cookie: no hay cookies" );
}
out.close(); //Close the output stream
}catch(Exception e)
{
ServletOutputStream out =
res.getOutputStream(); //Get a channel to the Web browser, so we can
send output
res.setContentType("text/html"); // Required
for HTTP
out.println("<HTML><HEAD><TITLE>CENTRO DE
ENSE�ANZA VIRTUAL</TITLE></HEAD>");
out.println("OUT firstServlet: " + e);
out.println("<p>Errores: " + error);
out.close(); //Close the output stream
}
}
-------------------- end source ----------------
Thanks in advanced....
E-mail: jcbueno@yahoo.com
BUENOV@santandersupernet.com
Technical Details
Message-ID:
<35CADCA1.6DFB99FA@santandersupernet.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: 10a146,8f6aae58303bfa18,start X-Google-Attributes: gid10a146,public X-Google-Thread: 1116f3,8f6aae58303bfa18,start X-Google-Attributes: gid1116f3,public From: Juan Carlos <BUENOV@santandersupernet.com> Subject: S.O.S. Servlets, maiday maiday maiday Date: 1998/08/07 Message-ID: <35CADCA1.6DFB99FA@santandersupernet.com> X-Deja-AN: 378803814 Content-Transfer-Encoding: 8bit Organization: Telefonica Transmision de Datos Content-Type: text/plain; charset=iso-8859-1 Mime-Version: 1.0 Newsgroups: comp.lang.java.programmer,es.comp.lenguajes.java