Confused about integration of Java file, JSPs, servlets? -


this first time working java , tomcat , i'm little confused how fits - i've googled endlessly can't seem wrap head around few concepts.

i have completed java program outputs bufferedimages. goal these images display on webpage.

i'm having trouble understanding how java file (.java) running in netbeans interacts servlet and/or jsp.

ideally, servlet or jsp (not 100% clear on how either of works. understand syntax looking @ various examples, however) output (the bufferedimages) when program runs , html file somehow interact whatever doing images displayed on webage. i'm not sure if possible. if suggest general order of going things, awesome.

in every example/tutorial find, no 1 uses .java files - there .classes in web-inf folder -- doesn't seem people using full on java programs. however, need .java program run can retrieve output , use on webapp.

any general guidance appreciated!

i think kind of documentation sadly lacking; many think example explanation, , wonderful things can out of example, explanation not 1 of them. i'm going attempt explain of overall concepts mentioned; aren't going solve buffered image display problem directly, unfortunately.

tomcat , other programs "web servers"; these programs accept internet connections other computers , return information in particular format. when enter "www" address in browser, string in address ends (as "request") @ web server, returns web page (also called "response"). tomcat, apache, jetty, jboss, , websphere similar programs sort of thing. in original form of world-wide-web, request string represented file on server machine, , web server's job return (html) file display in browser.

a servlet kind of java program runs on web servers. servlet java class methods defined javax.servlet.servlet interface. in webservers handle servlets, familiar configuration files can instruct web server program accept requests and, instead of returning html file (or whatever) server, instead execute servlet code. servlet, nature, returns content - think of program outputs html , you're on right track.

but turns out pain output complete html program -- there's tedious amount of html doesn't have "heavy lifting" need programming language of sort. have have java (or language) make database inquiries, filter results, etc., don't need java put in , hundreds of other tags modern web page needs.

so javaserverpage (jsp) special kind of hybrid, combination of html , things related servlets. can put java code directly in jsp file, considered better use html-like 'tags' interpreted "jsp compiler" , turned servlet. creator of jsp page learns how use these tags, (if correctly constructed) more logical web page creators java programming language is, , in fact doesn't have programmer @ all. programmer, working content-oriented person, creates tags page use describe how wants page look, programmer programming , content-person creates web pages it.

for specific problem, we'll need more detail you. envision program running , using information provided user part of request generate images? or images generated once , need display them? think that's topic question, actually.

this ought enough started. suggest wikipedia articles on these things more details, , luck getting head around concepts. hope has helped.


this addendum provided after comment made wanting slideshow.

an important web programming concept client-server , request-response nature of it. in traditional, non-javascript web environment, client (read browser) sends request server, , server sends bytes. there no ongoing connection between 2 computers after stream of bytes finishes, , there restrictions on how long stream of bytes can continue. additionally, outside of request , response, server has no capability send client unless client requests it; client 'drives' exchange of data.

so 'slideshow', instance, server periodically sends bytes representing additional image, not way html works (or meant work). 1 under user's control: user presses button each next picture, browser sends request next picture , appears in place previous 1 was. fits request-response paradigm.

now, effect of automatic slideshow possible using javascript. javascript, based on java otherwise unrelated, scripting language; part of html page, downloaded page browser, , runs in browser's environment (as opposed jsp/servlet, executes on server). can write timer in javascript, , can wait n seconds , send request server (for picture or whatever). javascript has own rules, etc., think idea keep in mind aren't doing html more.

if slideshow after, don't need jsp @ all. can create html page places picture being displayed, labels , text , etc., buttons stopping slideshow , forth, in html, , javascript requesting additional pictures.

you use jsp create page, , might depending on how complex page is, isn't going essential function: getting next picture slideshow. when browser requests jsp page:

  1. the request goes server,
  2. the server determines page want , jsp page,
  3. the server compiles page servlet if hasn't already,
  4. the servlet runs, producing html output according tags compiled java,
  5. the server returns html browser.

then server done, , more bytes won't go browser until request made.

again, hope has helped. example of slideshow has revealed basic concepts need understood web programming, servers, html, jsps, , javascript, , wish luck on journey through them all. , if come think of bit more convoluted seems needed be, well, won't first.


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -