• 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

Passing Variable from JSP to JAVA

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can anyone give me an idea on how to get a user input from jsp, pass it into the java page and then manipulate the value to be added into the database....

thanks...
 
Ranch Hand
Posts: 547
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
this would fit more in the Serlvet Forum.


The HTML Page (no matter with wath technology you generate it, be it JSP, PHP, ...) "lives" in the users browser.
To grab user input you need a form and input elements in the HTML page. When the submit button is clicked, then the browser sends the form data to the URL specified in the action attribute of the form.

You need to have something (a Servlet/JSP) "listening" on that URL. The servlet can access the form data through the HttpServletRequest Object (getParameter()/getParameters() methods) and insert the values in a DB, print them... whatever you want. Then the Servlet redirects or forwards to a result page. Voila....

hope this helped...

pascal
 
Eric Tan
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks alot for the info but if i want to avoid using servlets? can i use like javabean? where i play around with the setter and getter method? where after i post out the value in the textbox from the user input and set it to a variable. is java able to retrieve it out using get method and manipulate it?


thanks
 
Sheriff
Posts: 67746
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

Originally posted by Eric Tan:
but if i want to avoid using servlets?



Why? They're the right tool for the job.
 
Eric Tan
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
it's because my boss told us to use javabeans. she said it's because servlets is quite difficult and we are starting to learn java. so she said scared that we might not get the concept as compared to javabean
 
Eric Tan
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
it's because my boss told us to use javabeans. she said it's because servlets is quite difficult and we are starting to learn java. so she said scared that we might not get the concept as compared to javabean
 
Eric Tan
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
it's because my boss told us to use javabeans. she said it's because servlets is quite difficult and we are starting to learn java. so she said scared that we might not get the concept as compared to javabean
 
Eric Tan
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry that there was a repetition. it is because just now my dsl line was very unstable and i click a few times. didn't know that it repeatly posted my post. sorry about that!!
 
Ranch Hand
Posts: 2023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


You need to have something (a Servlet/JSP) "listening" on that URL. The servlet can access the form data through the HttpServletRequest Object (getParameter()/getParameters() methods) and insert the values in a DB, print them... whatever you want. Then the Servlet redirects or forwards to a result page.



JSP is a "servlet". You can ignore or replace "Servlet" to "JSP" in the above statement.
 
Eric Tan
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok. i will give it a thought and work on it. thanks alot.
if anyone has any links that may help me, do post for me please?
thanks alot!!
 
Without subsidies, chem-ag food costs four times more than organic. Or this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic