Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic requests

Status
Not open for further replies.

RicardoPereira

Programmer
Jun 3, 2003
255
PT
I have a form that is builded dynamically (the code is generated by an database access). When i submit the form i want to request the parameters using the database too.
Assuming that if i have a table with these two values:
String x = request.getParameter("a");
String y = request.getParameter("b");

How do i build the code to run this in my jsp page?
I start to do:

Arraylist ...
..
out.println(qry.getTest());

But what i see is the text
String x = request.getParameter("a");
String y = request.getParameter("b");

I dont whant the text, what i want is the code running.

Anyone could help?

Thanks
Ricardo
 
Hi,

Could be little bit more clear on what you are looking for Ricardo ?

If I understood your question correctly. You want to get the values of all the request parameters with out giving the parameter names in the next page..In that case you can use

Enumeration enum = request.getParameterNames();
Iterator iterator = enum.iterator();
while(iterator.hasNext())
{
String paramName = iterator.next().toString();
String paramValue = request.getParameter(paramName);
}

Cheeers,
Venu
 
No, it is not that,
what i want is:
I have a table in my database with two strings witch are:
String x = request.getParameter("a");
String y = request.getParameter("b");

Instead i got these information in text mode i want to run this code. My problem is that when i get the information from my database what i got is the text and not the running code.

Instead i write the code in my jsp file, i want to get him from my database.
How do i do that?

Thanks
Ricardo
 
Hi,

If I understood you correctly, In the JSP page when you say String x = request.getParameter("a");
String y = request.getParameter("b");
it should connect to the DB and get the values from the table for the values of "a" and "b" into "x" and "y" ?

Cheers,
Venu
 
No, what i want is all the code:
String x = request.getParameter("a");
String y = request.getParameter("b");

Instead i write in the jsp code i want to get the code from the database. I want to get the "String x = request.getParameter("a");" from the database and run in the jsp.
The problem is that when i get the string "String x = request.getParameter("a");" i got the text "String x = request.getParameter("a");" and not the running code.

Thanks
Ricardo
 
Hi
I tried what you said but wasn't successfull to execute the String at runTime. I hope there should be a technical answer which I am unable to.

Hope some one will answer this. Before that let put the question in a different way.

String runCode = "String x= request.getParameter(/"a/");";

out.println(runCode);

at the above statement it should create a String x with the value from the request.getParameter("a");

as now it just prints String x= request.getParameter(/"a/");

Is the question correct Ricardo ?

Cheers,
Venu

 
Yes, that's what i'am trying to do. Unhappyly without success.

I'am still wait for help :)


Ricardo
 
Hi,

All I can tell is The Java compiler considers a series of characters surrounded by quotation marks to be a literal string.

Cheers,
Venu
 
You need to build a &quot;scriptlet&quot; by encasing your java code in between <% and %>

like this:

<%
String x = request.getParameter(&quot;a&quot;);
String y = request.getParameter(&quot;b&quot;);
%>

JSP will recognize the lines as executable code.

If you don't use the <%...%> construct, JSP will think that it should print out the lines as HTML.
 
It is clearly that the java code must be between <% and %>.
But when you are trying to get an arraylist from the database you already have the <% and %> otherwise how do we executed the code?
My problem is: how do i put the string that i get from database to be interpreted as code??
That is my big question.

Thanks
Ricardo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top