This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Svelte and Sapper in Action and have Mark Volkmann on-line!
See this thread for details.
Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

best approach

 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi folks!
im new to servlet n jsp.i have done some basic technical stuff both in jsp n servlets. i wanna do some practical work now. so i need little guidence from u ppl.
wat should be the best approach towards development of applications using jsp n servlets. i mean should i go for only servlets, or jsp will be the best approach or mixing them both is better. or it depends wat kinda application im gonna develop. my question seems to be little stupid :d but this is wat confusion is in my mind.
bye
 
Author
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
quick and dirty advice?
use servlets for doing non visual stuff (you're not outputting HTML) and JSPs for doing purely visual stuff. Try and use beans in your JSP code as much as possible and as few scriptlets as you can manage. Otherwise, it often depends on the problem you are trying to solve. I'll give you the setup for one of my sites,
main site controller is a servlet, it takes URLs decodes them, gets the content and passes all the relevant values to the jsps
#
normal pages on the site, one jsp that includes some html files, and calls two beans to output the menus and the text.
#
response form on the site, servlet (no visual bit)
#
dynamic html editor for the site (administrator) - all jsps with tags.
one last thing to consider - there is one place where I would recommend using java code in jsps: I use them when I develop a part of the site so that I dont have to worry about compiling a servlet. Using jsps I can force reloading without restarting the server, and I dont have to manually compile the code. What I do od though is never mix a jsp that has java code with a jsp that has html in it - my rule to myself is a jsp has either but not both
 
reehan ishaque
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi chanoch!
thanx alot for ur reply. one more thing i wanna no is that how to send jsp or html files to the client from servlets. i have seen most of the books written on servlets sendin html through output streams. that seems little miserable. or using methods like sendRedirect(), requestDispatcher() etc..
 
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would use RequestDispatcher.forward(req, res) to forward to a jsp or html page.
 
Evacuate the building! Here, take this tiny ad with you:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic