• 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
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

JSP form with four inputs and one submit button

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

I need help to solve this problem, i want to search database based on 4 inputs, 2- form inputs and 2- selectboxes and one submit button in a JSP page....I am stuck here....please can anybody plzzz help me out :) , Just give me some idea or simple sample code would be great. This is very urgent for me.

Thanks in advance
Lissy.
 
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This doesn't seem to have much to do with JSP. Once the form is on the browser, it's just HTML.

The form action should address a servlet that can collect the submitted information and pass it to a model class that can perform the database manipulations.
 
lisy jessica
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the quick reply.....got some idea..will try.

Thanks
Lissy.
 
Bartender
Posts: 6663
5
MyEclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do post a specific problem if you have one. We can move the post appropriately based on the area you need help in.
 
lisy jessica
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I tried this but not able to get it, I need to retrieve data from db based on 2 form inputs and 2 selectboxes with one submit button... here is my code

AutoAssign.jsp



retrieve.jsp



This code is not working...when i enter the values and click submit ...it gives me "sorry couldn't find data"...Please anyone lookinto my code and tell me ..where the prob is...I am really stuck. I even tried with servlet...but same output(Sorry couldn't find data). Please help me.

Thanks in advance
Lissy.
 
Bartender
Posts: 1845
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Standard responses
1 - Don't use scriptlet code in JSP. Java code belongs in servlets/beans.
2 - The JDBC-ODBC bridge driver is . I suggest getting a real database, with a supported JDBC driver (MySQL, Oracle, MSSql...)
3 - When constructing sql statements with strings, you leave yourself open to sql injection attack. Instead your sql should use prepared statements to pass in the users values.

Specific to this code.
- You need to match up the names of your controls with the request parameters you are looking for.

For instance you have:


CABINET/EXCHANGE/TER <> Cabinet

The control "name" and the request parameter being retrieved must match.
I would suggest renaming the input components on AutoAssign.jsp to match what you have in the getParameter() calls in retrieve.jsp.

Suggested debugging steps
- print out the values of the search fields on your results page so that you can see they came through correctly.
- print out the sql generated to execute. Try running it on your database, and see what you get. Fiddle with it until you get sql that works, and then try translating the changes back to your code.

Things to think about
- are all your search parameters necessarily used to run the query? Particularly the remarks column will restrict the results too much I would think.
- consider writing the query logic into a java class. This code sample is based on patterns from 10 years ago. We've come a long way since then.


 
lisy jessica
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the quick reply...will try this and get back to you.

Thanks
Lissy.
 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Hey lisy, here a simple tutorial. It will help you to understand better the Stefan's advices.
 
lisy jessica
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Guys,

I got it....Thanks alot for the help. This is the best forum:)

Thanks
Lissy.
 
please buy this thing and then I get a fat cut of the action:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic