仓酷云

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 615|回复: 10
打印 上一主题 下一主题

[学习教程] JAVA教程之JSP - FAQ (5)

[复制链接]
飘灵儿 该用户已被删除
跳转到指定楼层
楼主
发表于 2015-1-18 11:27:36 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
还有就是总有人问我到底该学习什么语言,什么语言有前途,那么我的回答是不论是C,C++,java,.net,ruby,asp或是其他语言都可以学,编程的关键不是语言,而是思想。js33)Istheresomesortofeventthathappenswhenasessionobjectgetsboundorunboundtothesession?TOC



From:"Kirkdorffer,Daniel"<daniel.kirkdorffer@ATTWS.COM>

HttpSessionBindingListenerwillheartheeventsWhenanobjectisaddedand/orremovefromthesessionobject,orwhenthesessionisinvalidated,inwhichcasetheobjectsarefirstremovedfromthesession,whetherthesessionisinvalidatedmanuallyorautomatically(timeout).

34)IsthereawaytoexecuteaJSPfromthecomandlineorfrommyownapplication?TOC



ThereisalittletoolcalledJSPExecutorthatallowsyoutodojustthat.Thedevelopers(HendrikSchreiber<hs@webapp.de>&PeterRossbach<pr@webapp.de>)aimwasnottowriteafullblownservletengine,buttoprovidemeanstouseJSPforgeneratingsourcecodeorreports.ThereforemostHTTP-specificfeatures(headers,sessions,etc)arenotimplemented,i.e.noreponselineorheaderisgenerated.NeverthelessyoucanuseittoprecompileJSPforyourwebsite.JSPExecutorisGPLedandavailableatnochargeat:

http://www.webapp.de/jspexecutor.html

35)WhatshouldIuse,Model1orModel2?TOC



Whicheveroneworksforyou.Model2cangiveyoumorecontrol,especiallyifyouaredoingthingssuchasfilteringtheactualwebpagesaclientreceivesbecauseoflanguage.Model1isgenerallymoresimple.AmorefulldescriptionofModel1vsModel2isathttp://www.aptura.com/technology/jspBook_Architectures.html.

36)HowdoIdeleteacookiewithJSP?TOC



From:ChrisFesler<cfesler@InstantObjects.com>

Alittlemoreexperimentation,andIcameupwithamethodtodeletecookies.SaythatIhaveacookiecalled"foo,"thatIsetawhileago&I
wantittogoaway.Isimply:

<%
CookiekillCookie=newCookie("foo",null);
killCookie.setPath("/");
killCookie.setMaxAge(0);
response.addCookie(killCookie);
%>
Notethatthisis-not-howtheJSDKdocumentationindicatescookiesaretobedeleted,butwhattheheck--itseemstowork.



37)AretheretipsonthingstowatchoutforinJSP?TOC



ThereareanumberofthingstobewareofImsure,Ihavefoundoneinparticularsofar:

FromJohnLangley(langley@NEOTEK.MV.COM),donthavedirectoriesinyourpaththatarenotvalidJavaidentifiers(forexample,theystartwithanumber,orareanumber).AnumberofJSPimplementationsusethedirectoryyourJSPisinaspartofthepackagenameandifthatisinadirectorywithaninvalididentifierthenyouareoutofluck.
Bewareofserversideincludesnotrecompilingwhenyouhavechangedthem.SomeJSPengineswontcheckintoyourJSPorcreatedependencyliststoensurethattheentirecontentofyourJSPwillberecompiledifadependencyhaschanged.
Manyservletenginesdontnoticethatyouchangeyourbeans,sothatifyouchangeyourJSPandchangeabeanthatituses,althoughtheJSPwillreload,thebeanwillnot.Thiswillrequireyoutorestartyourserver.
TheVirtualMachinehassomeintrinsiclimitationsaswell(contributedbyCostinManolache),andtheseaffectyourJSP.FromVirtualMachineSpec:

64kentriesinconstantpool(thatmeansthecountofstringsyoucanuseinout.println(),plusallotherconstants<64k)
64kasthesizeofamethod(thatmeantheservice()methodcanthaveunlimitednumberofinstructions)
constantstringlimitis64k(bytes-notcharacters!)Thatmayexplainthe32K(sinceUnicodecharsare~2bytes-sometimes).
(itsnotthelimitofaString-justconstantString).
Othertipsappreciated!Emailmeatrvowles@esperanto.org.nz

38)HowdoyougetstartedwithJSPontheMacintosh?TOC



From:NielsPeterStrandberg<nps@HEM1.PASSAGEN.SE>

ThismailisforallMacusersthatwanttogetstartedwithJavaServerPagesontheMac.

ThislistisbaseonthemailsIgotfromMikeEngelhart<mengelhart@earthtrip.com>.Whohelpedmetogetmyserverstarted.ThanksMike!

JavaServerPagesistheJavaworldsanswertoActiveServerPagesonNT.SunhasmadeafreeversionwitchincludesaWebServerandanJSP
engine.Thepackageismadein100%pureJava.SoitrunsoneveryJavaplatform,anditisfree.

BeforeyoucancookyouownJavaServerPages,Youneedtobuildthe"JSPmachine".Andhereishowtodoit.

YouneedthelatestMRJfromApple.MRJ2.1canbefoundhere:http://www.apple.com/java/.Afterdownloadruntheinstallerandinstall
theMRJ.
YoualsoneedthelatestMRJSDK2.1(Imusing2.0andthatworksgreat),thatcanbefoundhere:http://developer.apple.com/java/text/download.html#sdk.AfterdownloadruntheinstallerandinstalltheMRJSDK.
Youalsoneedthe"JavaServerWDKEA(JavaServerWebDevelopmentKit1.0EA)"fromSun.Thiscanbefoundhere:http://developer.java.sun.com/developer/earlyAccess/jsp/.IdownloadedtheWinversion,butthereshouldbenoproblemifyoudownloadthe
Solarisversion.AfteryouhavedownloadedtheZip,unzipitusingZipItorStuffIt.Youhavetobearegisteredmemberofdeveloperconnection
togetaccesstothefiles,butthatitsfree.Sogoaheadanregisteryourself.
Afteryouhaveunzipedthezipfile,placetheunzipedfolder"jswdk-1.0-ea"onthedesktop.Nowlocatethe"MRJSDK2.1"folderand
openit.Insidethatfolderisanotherfoldernamed"JBindery"andinsidethatfolderanappwiththesamename.
Nowlaunchetheapp"jBindery".Clickonthe"Command"iconandaddthistotheClassnamefield:"com.sun.web.shell.Startup".Leavethe
optionalparametersblank.
Clickonthe"Classpath"icon.Clickonthe"add.zipfile..."buttonandaddthefollowingfiles:"webserver.jar"whichisintherootofyour"jswdk-1.0-ea"folder.Alsoaddthefollowingfileswhichareinthe"lib"folder:"jsp.jar"and"jspengine.jar"and"servlet.jar"
Clickonthe"addfolder..."buttonandadthefollowingfolder"beans"locateinexamples/WEB-INF/jsp/
Nowyouarereadytosavethesesettingasanclickableapplication.Clickonthe"SaveSettings..."button,andgiveyour"app"aname(ex.
JSPServer)andmakesurethecheckbox"saveasApp"ischecked.Makesurethatyousavetheappintherootofthe"jswdk-1.0-ea"folder.
Nowyouhaveembeddedthesesettinginanapplicationfile.Nowlocateyour"JSPServer"applicationanddoubleclickonit.Waitafewseconds,andyourservershouldbeupanrunning.TheappwillquitifitcantfindaIPnumber.GointoyourTCP/IPcontrolpanelandassignapermanentIPnumber(ex.127.0.0.1).Thentrytoruntheappagain.
TheJSPServerwillrunatport8080bydefault.Youcanchangethatbyopeningthe"default.cfg"fileinatexteditorandchangethe"server.port"from8080to80,witchisthedefaultportforWebServers.
Nowhereiswherethefunbegins.OpenyourwebbrowserandtypeintheIPnumberyouassignedtoyoumacintheTCP/IPcontrolpanel.(http://127.0.0.1)or(http://127.0.0.1:8080)ifyoudidntchangetheportsettinginthe"default.cfg"file.
Now,exploretheexampleandwhenyourareready,cookyourownJSP.
39)WhatApplicationServerssupportJSP?TOC



OriginallycontributedbyDanielKirkdorffer,daniel.kirkdorffer@attws.com.Seealsohttp://www.interpasnet.com/JSS/textes/jsp2.htmorhttp://www.Flashline.com/components/appservermatrix.jsp


40)WhathappenedtotheLOOPandDISPLAYtagsfromJSP0.92?TOC



TheywereleftoutinJSP1.0onwards.Therewasnoexplanationgiven.TheymaybeabletobeexpressedastagextensionsbutIhavenotinvestigatedthe1.1APIyettodeterminehowthatcouldbedone.

41)DoesJSPhaveabeanprovidingFileUploadfeatureslikeActiveXuploadcontrol?TOC



GetalookattheMultipartRequestobjectfromtheauthorof"JavaServletProgramming"(OReilly).Homepageishttp://www.servlets.com/index.html.Thezipfileforthisclassandotherusefulclassesisathttp://www.servlets.com/resources/com.oreilly.servlet/cos.zip.

42)SohowdoIuseEJBfromJSP?TOC



43)CanIjustabortprocessingaJSP?TOC



Yes.BecauseyourJSPisjustaservletmethod,youcanjustput(whereevernecessary)a

<%return;%>
44)"ImtryingtopassanobjectbetweenaservletandaJSPpage,butmyobjectisnullontheJSPpage.Whatcouldbewrong?"TOC



From:TimothyOwenReilly
HttpSessionobjectsarelimitedinscopetoaparticularservletzone.Inmycase,Isawthisbehaviourbecausemyservletwasinoneservletzone,andmyjspengine(GnuJSP)wasinanother.TryprintingoutthesessionidinbothyourservletandyourJSPpage[use:HttpSession.getId()],ifitsdifferentinboth,thenobviouslyeachsideoftheequationisusingadifferentsessionframework,andyoucouldhavethesameproblemasIdid.

RunningbothmyservletsandGnuJSPinthesameservletzonesolvedthisproblem.

Note:TheobservedbehaviourandsolutionwereunderApacheJServ1.1andGnuJSP1.0
什么时候上述的三种开发工具能和三为一,什么时候java的竞争力才更强,才有机会拉拢更多的程序员投入到对java的开发上,因为到时的开发工具将会比.net的更简单。还有一点也很关键,什么时候java推出的jsf能成为真正意义上的标准。
因胸联盟 该用户已被删除
沙发
发表于 2015-1-20 19:48:19 | 只看该作者
是一种简化的C++语言 是一种安全的语言,具有阻绝计算机病毒传输的功能
活着的死人 该用户已被删除
板凳
发表于 2015-1-29 18:11:37 | 只看该作者
你一定会高兴地说,哈哈,原来成为Java高手就这么简单啊!记得Tomjava也曾碰到过一个项目经理,号称Java很简单,只要三个月就可以学会。
再现理想 该用户已被删除
地板
发表于 2015-1-30 17:02:46 | 只看该作者
Sun公司看见Oak在互联网上应用的前景,于是改造了Oak,于1995年5月以Java的名称正式发布。Java伴随着互联网的迅猛发展而发展,逐渐成为重要的网络编程语言。
5#
发表于 2015-2-5 01:45:42 | 只看该作者
任职于太阳微系统的詹姆斯·高斯林等人于1990年代初开发Java语言的雏形,最初被命名为Oak,目标设置在家用电器等小型系统的程序语言
兰色精灵 该用户已被删除
6#
发表于 2015-2-6 00:26:13 | 只看该作者
如果你学过HTML,那么事情要好办的多,如果没有,那你快去补一补HTML基础吧。其实JSP中的Java语法也不多,它更象一个脚本语言,有点象ASP。
谁可相欹 该用户已被删除
7#
发表于 2015-2-14 15:48:25 | 只看该作者
是一种将安全性(Security)列为第一优先考虑的语言
不帅 该用户已被删除
8#
发表于 2015-3-6 21:09:07 | 只看该作者
你快去找一份Java的编程工作来做吧(如果是在校学生可以去做兼职啊),在实践中提高自己,那才是最快的。不过你得祈祷在公司里碰到一个高手,而且他 还愿意不厌其烦地教你,这样好象有点难哦!还有一个办法就是读开放源码的程序了。我们知道开放源码大都出自高手,他们设计合理,考虑周到,再加上有广大的程序员参与,代码的价值自然是字字珠叽,铿锵有力(对不起,偶最近《金装四大才子》看多了)。
小魔女 该用户已被删除
9#
发表于 2015-3-11 19:39:03 | 只看该作者
是一种突破用户端机器环境和CPU
简单生活 该用户已被删除
10#
发表于 2015-3-19 10:15:45 | 只看该作者
一般学编程语言都是从C语开始学的,我也不例外,但还是可能不学过程语言而直接学面向对象语言的,你是刚接触语言,还是从C开始学比较好,基础会很深点,如果你直接学习JAVA也能上手,一般大家在学语言的时候都记一些语言的关键词,常有的包和接口等。再去做逻辑代码的编写,以后的学习过程都是从逻辑代码编写中提升的,所以这方面都是经验积累的。你要开始学习就从
变相怪杰 该用户已被删除
11#
发表于 2015-3-27 17:12:19 | 只看该作者
任职于太阳微系统的詹姆斯·高斯林等人于1990年代初开发Java语言的雏形,最初被命名为Oak,目标设置在家用电器等小型系统的程序语言
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|仓酷云 鄂ICP备14007578号-2

GMT+8, 2024-11-15 13:53

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表