本科毕业设计关于java技术外文翻译.docx

上传人:b****6 文档编号:15724173 上传时间:2023-07-07 格式:DOCX 页数:26 大小:34.79KB
下载 相关 举报
本科毕业设计关于java技术外文翻译.docx_第1页
第1页 / 共26页
本科毕业设计关于java技术外文翻译.docx_第2页
第2页 / 共26页
本科毕业设计关于java技术外文翻译.docx_第3页
第3页 / 共26页
本科毕业设计关于java技术外文翻译.docx_第4页
第4页 / 共26页
本科毕业设计关于java技术外文翻译.docx_第5页
第5页 / 共26页
本科毕业设计关于java技术外文翻译.docx_第6页
第6页 / 共26页
本科毕业设计关于java技术外文翻译.docx_第7页
第7页 / 共26页
本科毕业设计关于java技术外文翻译.docx_第8页
第8页 / 共26页
本科毕业设计关于java技术外文翻译.docx_第9页
第9页 / 共26页
本科毕业设计关于java技术外文翻译.docx_第10页
第10页 / 共26页
本科毕业设计关于java技术外文翻译.docx_第11页
第11页 / 共26页
本科毕业设计关于java技术外文翻译.docx_第12页
第12页 / 共26页
本科毕业设计关于java技术外文翻译.docx_第13页
第13页 / 共26页
本科毕业设计关于java技术外文翻译.docx_第14页
第14页 / 共26页
本科毕业设计关于java技术外文翻译.docx_第15页
第15页 / 共26页
本科毕业设计关于java技术外文翻译.docx_第16页
第16页 / 共26页
本科毕业设计关于java技术外文翻译.docx_第17页
第17页 / 共26页
本科毕业设计关于java技术外文翻译.docx_第18页
第18页 / 共26页
本科毕业设计关于java技术外文翻译.docx_第19页
第19页 / 共26页
本科毕业设计关于java技术外文翻译.docx_第20页
第20页 / 共26页
亲,该文档总共26页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

本科毕业设计关于java技术外文翻译.docx

《本科毕业设计关于java技术外文翻译.docx》由会员分享,可在线阅读,更多相关《本科毕业设计关于java技术外文翻译.docx(26页珍藏版)》请在冰点文库上搜索。

本科毕业设计关于java技术外文翻译.docx

本科毕业设计关于java技术外文翻译

附录一外文资料原文:

ABOUTJAVATECHNOLOGY

ServletsandJSP:

AnOverview

1.WhatareJavaServlets?

ServletsareJavatechnology'sanswertoCGIprogramming.TheyareprogramsthatrunonaWebserverandbuildWebpages.BuildingWebpagesontheflyisuseful(andcommonlydone)foranumberofreasons:

∙TheWebpageisbasedondatasubmittedbytheuser.Forexampletheresultspagesfromsearchenginesaregeneratedthisway,andprogramsthatprocessordersfore-commercesitesdothisaswell.

∙Thedatachangesfrequently.Forexample,aweather-reportornewsheadlinespagemightbuildthepagedynamically,perhapsreturningapreviouslybuiltpageifitisstilluptodate.

∙TheWebpageusesinformationfromcorporatedatabasesorothersuchsources.Forexample,youwouldusethisformakingaWebpageatanon-linestorethatlistscurrentpricesandnumberofitemsinstock.

2.WhataretheAdvantageofServletsOver"Traditional"CGI?

Javaservletsaremoreefficient,easiertouse,morepowerful,moreportable,andcheaperthantraditionalCGIandthanmanyalternativeCGI-liketechnologies.(Moreimportantly,servletdevelopersgetpaidmorethanPerlprogrammers:

-).

∙Efficient.WithtraditionalCGI,anewprocessisstartedforeachHTTPrequest.IftheCGIprogramdoesarelativelyfastoperation,theoverheadofstartingtheprocesscandominatetheexecutiontime.Withservlets,theJavaVirtualMachinestaysup,andeachrequestishandledbyalightweightJavathread,notaheavyweightoperatingsystemprocess.Similarly,intraditionalCGI,ifthereareNsimultaneousrequesttothesameCGIprogram,thenthecodefortheCGIprogramisloadedintomemoryNtimes.Withservlets,however,thereareNthreadsbutonlyasinglecopyoftheservletclass.ServletsalsohavemorealternativesthandoregularCGIprogramsforoptimizationssuchascachingpreviouscomputations,keepingdatabaseconnectionsopen,andthelike.

∙Convenient.Hey,youalreadyknowJava.WhylearnPerltoo?

Besidestheconvenienceofbeingabletouseafamiliarlanguage,servletshaveanextensiveinfrastructureforautomaticallyparsinganddecodingHTMLformdata,readingandsettingHTTPheaders,handlingcookies,trackingsessions,andmanyothersuchutilities.

∙Powerful.JavaservletsletyoueasilydoseveralthingsthataredifficultorimpossiblewithregularCGI.Foronething,servletscantalkdirectlytotheWebserver(regularCGIprogramscan't).Thissimplifiesoperationsthatneedtolookupimagesandotherdatastoredinstandardplaces.Servletscanalsosharedataamongeachother,makingusefulthingslikedatabaseconnectionpoolseasytoimplement.Theycanalsomaintaininformationfromrequesttorequest,simplifyingthingslikesessiontrackingandcachingofpreviouscomputations.

∙Portable.ServletsarewritteninJavaandfollowawell-standardizedAPI.Consequently,servletswrittenfor,sayI-PlanetEnterpriseServercanrunvirtuallyunchangedonApache,MicrosoftIIS,orWebStar.ServletsaresupporteddirectlyorviaapluginonalmosteverymajorWebserver.

∙Inexpensive.ThereareanumberoffreeorveryinexpensiveWebserversavailablethataregoodfor"personal"useorlow-volumeWebsites.However,withthemajorexceptionofApache,whichisfree,mostcommercial-qualityWebserversarerelativelyexpensive.Nevertheless,onceyouhaveaWebserver,nomatterthecostofthatserver,addingservletsupporttoit(ifitdoesn'tcomepreconfiguredtosupportservlets)isgenerallyfreeorcheap.

3.WhatisJSP?

JavaServerPages(JSP)isatechnologythatletsyoumixregular,staticHTMLwithdynamically-generatedHTML.ManyWebpagesthatarebuiltbyCGIprogramsaremostlystatic,withthedynamicpartlimitedtoafewsmalllocations.ButmostCGIvariations,includingservlets,makeyougeneratetheentirepageviayourprogram,eventhoughmostofitisalwaysthesame.JSPletsyoucreatethetwopartsseparately.Here'sanexample:

DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.0Transitional//EN">

WelcometoOurStore

WelcometoOurStore

Welcome,

--Usernameis"NewUser"forfirst-timevisitors-->

<%out.println(Utils.getUserNameFromCookie(request));%>

Toaccessyouraccountsettings,click

here.

RegularHTMLforalltherestoftheon-linestore'sWebpage.

4.WhataretheAdvantagesofJSP?

∙vs.ActiveServerPages(ASP).ASPisasimilartechnologyfromMicrosoft.TheadvantagesofJSParetwofold.First,thedynamicpartiswritteninJava,notVisualBasicorotherMS-specificlanguage,soitismorepowerfulandeasiertouse.Second,itisportabletootheroperatingsystemsandnon-MicrosoftWebservers.

∙vs.PureServlets.JSPdoesn'tgiveyouanythingthatyoucouldn'tinprincipledowithaservlet.Butitismoreconvenienttowrite(andtomodify!

)regularHTMLthantohaveazillionprintlnstatementsthatgeneratetheHTML.Plus,byseparatingthelookfromthecontentyoucanputdifferentpeopleondifferenttasks:

yourWebpagedesignexpertscanbuildtheHTML,leavingplacesforyourservletprogrammerstoinsertthedynamiccontent.

∙vs.Server-SideIncludes(SSI).SSIisawidely-supportedtechnologyforincludingexternally-definedpiecesintoastaticWebpage.JSPisbetterbecauseitletsyouuseservletsinsteadofaseparateprogramtogeneratethatdynamicpart.Besides,SSIisreallyonlyintendedforsimpleinclusions,notfor"real"programsthatuseformdata,makedatabaseconnections,andthelike.

∙vs.JavaScript.JavaScriptcangenerateHTMLdynamicallyontheclient.Thisisausefulcapability,butonlyhandlessituationswherethedynamicinformationisbasedontheclient'senvironment.Withtheexceptionofcookies,HTTPandformsubmissiondataisnotavailabletoJavaScript.And,sinceitrunsontheclient,JavaScriptcan'taccessserver-sideresourceslikedatabases,catalogs,pricinginformation,andthelike.

∙vs.StaticHTML.RegularHTML,ofcourse,cannotcontaindynamicinformation.JSPissoeasyandconvenientthatitisquitefeasibletoaugmentHTMLpagesthatonlybenefitmarginallybytheinsertionofsmallamountsofdynamicdata.Previously,thecostofusingdynamicdatawouldprecludeitsuseinallbutthemostvaluableinstances.

Overview

JavaServerPages(JSP)letsyouseparatethedynamicpartofyourpagesfromthestaticHTML.YousimplywritetheregularHTMLinthenormalmanner,usingwhateverWeb-page-buildingtoolsyounormallyuse.Youthenenclosethecodeforthedynamicpartsinspecialtags,mostofwhichstartwith"<%"andendwith"%>".Forexample,hereisasectionofaJSPpagethatresultsinsomethinglike"ThanksfororderingCoreWebProgramming"forURLofhttp:

//host/OrderConfirmation.jsp?

title=Core+Web+Programming:

Thanksfororderinga

<%=request.getParameter("title")%>

Younormallygiveyourfilea.jspextension,andtypicallyinstallitinanyplaceyoucouldplaceanormalWebpage.AlthoughwhatyouwriteoftenlooksmorelikearegularHTMLfilethanaservlet,behindthescenes,theJSPpagejustgetsconvertedtoanormalservlet,withthestaticHTMLsimplybeingprintedtotheoutputstreamassociatedwiththeservlet'sservicemethod.Thisisnormallydonethefirsttimethepageisrequested,anddeveloperscansimplyrequestthepagethemselveswhenfirstinstallingitiftheywanttobesurethatthefirstrealuserdoesn'tgetamomentarydelaywhentheJSPpageistranslatedtoaservletandtheservletiscompiledandloaded.NotealsothatmanyWebserversletyoudefinealiasesthatsothataURLthatappearstoreferenceanHTMLfilereallypointstoaservletorJSPpage.

AsidefromtheregularHTML,therearethreemaintypesofJSPconstructsthatyouembedinapage:

scriptingelements,directives,andactions.ScriptingelementsletyouspecifyJavacodethatwillbecomepartoftheresultantservlet,directivesletyoucontroltheoverallstructureoftheservlet,andactionsletyouspecifyexistingcomponentsthatshouldbeused,andotherwisecontrolthebehavioroftheJSPengine.Tosimplifythescriptingelements,youhaveaccesstoanumberofpredefinedvariablessuchasrequestinthesnippetabove.

Notethatthistutorialcoversversion1.0oftheJSPspecification.JSPhaschangeddramaticallysinceversion0.92,andalthoughthesechangeswerealmostentirelyforthebetter,youshouldnotethatversion1.0JSPpagesarealmosttotallyincompatiblewiththeearlierJSPengines.

2.SyntaxSummary

JSPElement

Syntax

Interpretation

Notes

JSPExpression

<%=expression%>

Expressionisevaluatedandplacedinoutput.

XMLequivalentis

expression>

expression

expression>.Predefinedvariablesarerequest,response,out,session,application,config,andpageContext(availableinscriptletsalso).

JSPScriptlet

<%code%>

Codeisinsertedinservicemethod.

XMLequivalentis

scriptlet>

code

scriptlet>.

JSPDeclaration

<%!

code%>

Codeisinsertedinbodyofservletclass,outsideofservicemethod.

XMLequivalentis

declaration>

code

declaration>.

JSPpageDirective

<%@pageatt="val"%>

Directionstotheservletengineaboutgeneralsetup.

XMLequivalentis

directive.page att="val"\>.Legalattributes,withdefaultvaluesinbold,are:

∙import="package.class"

∙contentType="MIME-Type"

∙isThreadSafe="true|false"

∙session="true|false"

∙buffer="sizekb|none"

∙autoflush="true|false"

∙extends="package.class"

∙info="message"

∙errorPage="url"

∙isErrorPage="true|false"

∙language="java"

JSPincludeDirective

<%@inclu

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 农林牧渔 > 林学

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2