This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JSP and the fly likes Passing Variable from JSP to JAVA Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Passing Variable from JSP to JAVA" Watch "Passing Variable from JSP to JAVA" New topic
Author

Passing Variable from JSP to JAVA

Eric Tan
Ranch Hand

Joined: Oct 11, 2006
Posts: 72
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...
pascal betz
Ranch Hand

Joined: Jun 19, 2001
Posts: 547
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

Joined: Oct 11, 2006
Posts: 72
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
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60774
    
  65

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


Why? They're the right tool for the job.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Eric Tan
Ranch Hand

Joined: Oct 11, 2006
Posts: 72
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

Joined: Oct 11, 2006
Posts: 72
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

Joined: Oct 11, 2006
Posts: 72
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

Joined: Oct 11, 2006
Posts: 72
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!!
wise owen
Ranch Hand

Joined: Feb 02, 2006
Posts: 2023

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

Joined: Oct 11, 2006
Posts: 72
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!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Passing Variable from JSP to JAVA
 
Similar Threads
reply immediately
Is there a way to read HTML into a string from a URL
How to Pass ArrayList to Applet?
Servlet & JSP
Sender's Address