• 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

Need Generic code - if it exists - for JSP & Servlet & JDBC

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does anybody have suggestions on where I should start?

I need java code for these things:

Must be JSP & Servlet
The user must be able to add/update/delete/browse a database table. (any database is OK - I know how to customize it for what I need)

As opposed to starting from scratch, does anybody have any suggestions?

thanks,
Keith
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually I kinda recommend starting from scratch. I've seen people grab a running example and modify it to their needs and it almost always comes out really bad. No, make that always.

Take very small steps. Try to write only a handful of lines of code between tests. Come back here with little chunks of code that almost work. The gang feeds on these.

And give some more background - is this school work? Just for fun? Career critical?
 
Keith Thompson
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Career Critical. Supposed to be totally completed in 3 days. Supposed to start from scratch(completely from scratch - nothing provided). Is this reasonable? Somebody here tell me if this is reasonable or not - because I really don't know.

Keith Thompson
 
Ranch Hand
Posts: 572
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think this could be done in 3 days if you know java. Becuase Servlets are java class file and if you know java already then you can do it easily. Otherwise you will have to learn the basic java first, then JDBC,Servlets and Jsps.
 
Stan James
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Career critical and 3 days means anything goes.

Google for "sevlet tutorial" and you'll find zillions of examples. Your servlet engine probably shipped with some samples, too. To stick with the "from scratch" theme, start with an empty file in your editor and copy in only lines that you completely understand and know you need. Read a few tutorials and see what they all have in common - that's a good clue to the bare minimum starting point. Make a real effort to see what you can leave out. I just love deleting code!

Couple ideas ... always have the user post or get to a servlet. These are pure java, no html, and well suited to figuring out what the user wants to get or update. Put the results of the action in an object on the session and redirect control to a JSP to generate HTML. These are mostly HTML with just enough script to get data from that object on the session and populate the screen. Be sure to remove the object from the session at end or the session will grow forever.

A neat pattern is post-redirect-get. The user posts a screen full of updates to the server. The server does the updates and sends a redirect instruction back to the browser. The browser does a get on the specified page which retrieves the data to confirm the update. This neatly separates your update and retrieval code, and allows the user to hit "refresh" on the results page.

Hope that helps! Check in often as you get into this!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic