Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

having a parameter in my JavaBean  RSS feed

 
Wall Schnok
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I'm calling a .jsp page with a parameter :
<a href=http://my_server/my_page.jsp?my_parameter="the_value">
I need this "the_value" in the JavaBean used by my .JSP .
Someone suggested me
<%=request.getParameter("my_parameter")%>
that works well in my .jsp source , but not in my .java file (of my JavaBean ).
I tried :
String my_string = request.getParameter("my_parameter");
in the .java file but it tells me that ( obvious ) doesn't recognize "request" command .
What to do ?
Thanks a lot.
w.
 
Thandapani Saravanan
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When a name value pair is sent to the Resource (JSP, HTML, Servlet) through HTTP it is visible to the resource only. You can send this value as a parameter to method or a property to a JavaBean
 
Wall Schnok
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
at least , it's possible to do it or not ?
can you give me some example ?
thanks a lot .
 
Wall Schnok
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you're talking about this type of calling , right ?:
<%=my_javabean.my_function(request.getParameter("my_parameter");%>
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"wall",
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please log in with a new name which meets the requirements.
Thanks.
 
maha anna
Ranch Hand
Posts: 1467
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Slightly chage your code like this.
<%
String val = request.getParameter("my_parameter");
Bean bean = new Bean();
bean.method1(val);
%>
regds
maha anna
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!