• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

best approach

 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would use RequestDispatcher.forward(req, res) to forward to a jsp or html page.
 
reply
    Bookmark Topic Watch Topic
  • New Topic