Thread View: comp.lang.java.programmer
1 messages
1 total messages
Started by Juan Carlos
Fri, 07 Aug 1998 00:00
S.O.S. Servlets, maiday maiday maiday
Author: 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
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads