|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
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能成为真正意义上的标准。 |
|