Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

referencing a value in a textfield without using request.getParameter

 
payal kapadia
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi ...
need some help in figuring out this...

how do u reference a value from a text field without using request.getPArameter in jsp.I need to parse this value to a bean file tht calls the database.

PPLLLLLLZZZ help!!
ciao
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64827
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's wrong with request.getParameter()?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64827
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And...

JavaRanch is a community of people from all over the world, many of who are not native English speakers. While using abbreviations like "u" instead of spelling out "you" is convenient when text messaging your friends on a cell phone or in a chat room, it presents an extra challenge to those that are already struggling with English. Additionally, such shortcuts may confound automated translation tools that patrons of the Ranch may be making use of.

I would like to ask for your help in making the content of JavaRanch a little easier to read for everybody that visits here by not using such abbreviations.

thanks,
bear
JSP Forum Bartender
 
pradeep jaladi
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I think you need to parse the string into integer (or) parsing of the string also . Get the value into the string "beforeParse" and write one java program to parse the string to your desired type and return the value into the data type you required.

example.
1.jsp
< jsp:useBean id="parse" class="parse" >
.....
String beforeParse = request.getParameter("myvalue");
int i = parse(beforeParse);

parse.java

public int parse(String s)
{
// write the neccessary code here

}

I think this will be help full to you.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As an academic excercise, this could be pretty interesting -- sort of like Perl before mod_cgi. Otherwise, I can't see any good reason not to use getParameter.

Look at the HttpServletRequest API:
http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/http/HttpServletRequest.html

Specifically, look at getQueryString and getInputStream (which is in the superclass, ServletRequest).

You'll have some string parsing to do. If this is for a class assignment, remember, there can be more than one HTTP form field with the same name.

Be sure to post back and let us know why you're doing this.
 
Vijay Sharma
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey what is the Problem with getParameter method,Whatever u want to do,Simply call this method,It will return u some String.Then Parse that String And Use that variable in whatever way u do like.Or is it necessary that u don't want to use getParameter then the case may be different.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by John Dhoom:
Hey what is the Problem with getParameter method,Whatever u want to do,Simply call this method,It will return u some String.Then Parse that String And Use that variable in whatever way u do like.Or is it necessary that u don't want to use getParameter then the case may be different.


John,
Did you read the third post in this thread?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic