初学JSP的困惑,请专家指点迷津。。。

iamniou 2002-03-03 02:49:38
初学JSP的困惑,请专家指点迷津。。。
我曾经学习和使用过PB7和MSSQL2000,最近学习JSP已经将近50天,首先我学习JAVA 2的基本语法和一些基本的东西(看的是《JAVA 2编程指南》,电子工业出版社),然后又学习的了Dreamweaver UltraDev 4的一些基本网页的制作,现在在看《JSP深入编程》(希望电子出版社的)。我学习这些天以来,总感觉还没有入门,让我摸不着边。
以前在学习PB时,感觉很快就入门了,而且PB的书里有它的函数的详细的说明,可在学习JAVA时,我都找不到有关JAVA函数的详细说明的书籍,总感觉有关JAVA的书籍讲的太乱,不系统(也许是我的水平太低)。如:在JSP里的response对象中,使用cookie,有如下代码:
<% cookie killmycookie = new cookie("mycookie",null);
killmycookie.setMaxAge(0); //请问:这里如果把setMaxAge(0)写成setmaxage(0),行不行?
killmycookie.setPath("/");
response.addcookie(killmycookie);
%>
其中,我就想知道setMaxAge()和setPath()这两个函数的详细用法,但JSP书中就一带而过,我想知道的话,该怎么办?不只有没有详细介绍JAVA函数的工具书?
不知是不是我的学习方法不对?还是什么?恳请各位专家指点一二。。。。
不胜感谢。
...全文
35 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
阮小七 2002-03-03
  • 打赏
  • 举报
回复
刚才又看到的一点东西,可能对你有用:
---------------------------------------------------------
public class Cookie
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable
Encapsulates HTTP cookies.

Cookies are use to keep track of users for sessions and to recognize users back for personalization.

When deleting cookies or changing the time, it's important to set the same domain and path as originally passed. Browsers distinguish cookies with different domain and path.

Cookie myCookie = new Cookie("mycookie", "myvalue");
myCookie.setPath("/path");
myCookie.setDomain("mydom.com");
// will live for a month
myCookie.setMaxAge(60 * 24 * 3600);
response.addCookie(myCookie);

To delete the above cookie, you'll need to do something like the following:

Cookie myCookie = new Cookie("mycookie", "myvalue");
myCookie.setPath("/path");
myCookie.setDomain("mydom.com");
// kill the cookies
myCookie.setMaxAge(0);
response.addCookie(myCookie);
阮小七 2002-03-03
  • 打赏
  • 举报
回复
java对大小写敏感……也就是说,函数名不能随便大小写

函数的用法,请参考javax.servlet.http.Cookie的文档
-----------------------------------------------
setMaxAge
public void setMaxAge(int maxAge)
Sets the max age of a cookie. Setting maxAge to zero deletes the cookie. Setting it to something large makes the cookie persistent. If maxAge is not set, the cookie will only last for the session.
Parameters:
maxAge - lifetime of the cookie in seconds.
-----------------------------------------------
setPath
public void setPath(java.lang.String path)
Sets the URL path of a cookie. Normally, cookies will just use the root path.
-----------------------------------------------
这是javax.servlet.http.Cookie文档里面的,我不清楚你要的详细用法是什么,你找相应的文档看一下就知道了

btw:我不是专家,我只能说出这么多

23,407

社区成员

发帖
与我相关
我的任务
社区描述
Java 非技术区
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧