File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes Passing values to param value dynamically in jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Passing values to param value dynamically in jsp" Watch "Passing values to param value dynamically in jsp" New topic
Author

Passing values to param value dynamically in jsp

Neeba Rebbaca
Ranch Hand

Joined: Oct 21, 2008
Posts: 136
I need to pass param values dynamically.If i tried to assign a variable to value attribute ,Its saying, must enclose within string. How to assign value dynamically?

My code goes here,


In the place of "12" i want to dynamically pass values.
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3775

What did you try, which caused the error?


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Neeba Rebbaca
Ranch Hand

Joined: Oct 21, 2008
Posts: 136
i tried to get the request parameter and pass the value to the applet.

Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874


Should work, provided EL is on.
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Neeba Rebbaca wrote:i tried to get the request parameter and pass the value to the applet.



Not a good idea anyway. Your variable str is not thread safe.
Neeba Rebbaca
Ranch Hand

Joined: Oct 21, 2008
Posts: 136
Is there any other best practise?
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3775

Neeba Rebbaca wrote:Is there any other best practise?

Without scriptlet you can directly get the reuest params through "${param.nameOfTheParameter}"
Neeba Rebbaca
Ranch Hand

Joined: Oct 21, 2008
Posts: 136
can you explain me in detail(because i'm new to J2EE)


do you mean this,

>
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3775

Neeba Rebbaca wrote:can you explain me in detail(because i'm new to J2EE)
do you mean this,
>


"param" is an implicit EL variable (of type Map) which holds request parameter name/value pairs. You can access the parameter value by it's name like above.
Neeba Rebbaca
Ranch Hand

Joined: Oct 21, 2008
Posts: 136

i tried to get the request parameter and pass the value to the applet.And this is my html,here i want to pass the parameter test's value (2) to the applet







here, the output should display as 2 , but i'm getting only a empty string.where i'm making the mistake.
Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1398
    
    6

Not sure whether we can mention any query string in form action, however this should work.



Swastik
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3775

Neeba Rebbaca wrote:.. here, the output should display as 2 , but i'm getting only a empty string.where i'm making the mistake.

That's not possible with "form" tag which meant to submit the form data. How ever you can have a "anchor" tag somewhere and that also will work like the "input" tag suggested above.
OR
Bhaavyaa K. Kapoor
Greenhorn

Joined: Oct 14, 2009
Posts: 5
Neeba Rebbaca wrote:i tried to get the request parameter and pass the value to the applet.


This will solve your problem
<%=expression %>.These are the expression tags.It is equivalent println statement in java.


SCJP 1.6 98%
Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1398
    
    6

Correct, but what you are using is not using expression language which is more recommended these days.
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3775

Bhaavyaa K. Kapoor wrote:
Neeba Rebbaca wrote:i tried to get the request parameter and pass the value to the applet.


This will solve your problem
<%=expression %>.These are the expression tags.It is equivalent println statement in java.

Hi Bhaavyaa, Welcome to JavaRanch . These days people never use Java code (scriptlet,scriptlet expressions etc..) in JSPs but JSTL,EL, Standard & Custom actions.
Bhaavyaa K. Kapoor
Greenhorn

Joined: Oct 14, 2009
Posts: 5
Vijitha Kumara wrote:
Bhaavyaa K. Kapoor wrote:
Neeba Rebbaca wrote:i tried to get the request parameter and pass the value to the applet.


This will solve your problem
<%=expression %>.These are the expression tags.It is equivalent println statement in java.

Hi Bhaavyaa, Welcome to JavaRanch . These days people never use Java code (scriptlet,scriptlet expressions etc..) in JSPs but JSTL,EL, Standard & Custom actions.

Thanks for telling me.I have just started learning jsp and hence i am just a beginner
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Passing values to param value dynamically in jsp
 
Similar Threads
jsp:plugin using applet & mayscript
how to pass values from jsp to applet
JSF and dynamic applet param passing
send session from applet to servlet
Applet not loaded in jsp