• 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

need of Design Pattern with servlet

 
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,

I am writing a servlet which updates multiple database tables at once...
now I have a HTML front end file and a servlet. and I am printing the output about successful and unsuccessful insertion using out.print() where out is a PrintWriter to Response object of servlet

Total business logic is there in the servlet

My questions are

1. Is it possible for me to adopt MVC pattern for this

2. if not How I should organize my code...How to divide and place....

3.Where to keep the output info....
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
  • Browser hits servlet (controller) and gets forwared to the JSP (view) with the form
  • User fills out form and submits. Form is submitted to the servlet.
  • Servlet parses form parameters. If OK, instanciates bean (model) and passes values to it. The bean has all the JDBC code in it.
  • The bean performs all database function and returns results (possibly in the form of another bean) to the servlet.
  • The servlet binds the results to the request object and forwards to the JSP for display.
  • The JSP (using either jsp:getProperty or EL, or JSTL..) presents the results to the user.

  •  
    Hareesh Ram Chanchali
    Ranch Hand
    Posts: 110
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    hi ben,

    I am updating 20 to 30 tables on a single click..
    It is an application of Data Population from MS-Excel file to Oracle...

    I wont fill the data in forms ...only the input i give is the file name with location... I should be able to display about successful/unsuccessful insertions rowwise
     
    Ranch Hand
    Posts: 2874
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Do as Ben directed. Then put some logic while inserting data in tables. You can populate a collection of a Bean, which would have appropriate message in it. Then bind that collection with your request object, and so forth. . . so forth.
     
    Ben Souther
    Sheriff
    Posts: 13411
    Firefox Browser VI Editor Redhat
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    You'll also want to look into a file upload library.
    I use http://jakarta.apache.org/commons/fileupload
     
    reply
      Bookmark Topic Watch Topic
    • New Topic