• Post Reply Bookmark Topic Watch Topic
  • New Topic

take parameters in jsp and put in select sql  RSS feed

 
Tatiana Schineider
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I'm trying to get a value of my parameter, but can not.

I know when I send the content to show it, is normal, for example:



I'm trying to put the contents of it to this query



Does anyone have any idea?
thank you
 
Paul Clapham
Sheriff
Posts: 22374
42
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The best idea would be to not do it in a JSP. Do it in a servlet, or something else which is naturally Java code. And for the JDBC part of the question, a PreparedStatement with a ? parameter would be the best choice.
 
Epifanio Guzman
Greenhorn
Posts: 16
Chrome Fedora MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
:wink: i think this is already resolved.
But here's my answer. Maybe it could be helpful for someone.

Like Paul, i think it should be in a class.

1.- jsp
send param using text fiel, in FORM:
<input name=\"txtStrGeneric1\" type=\"text\" id=\"txtStrGeneric1\"></td> \n";

using param:
url ..... +"&StrGeneric1="+StrGeneric1;

2.- jsp
get param from text fiel.
try{StrGeneric1 = request.getParameter("txtStrGeneric1");}
catch(Exception e){}

get param from a param.
try{StrGeneric1 = request.getParameter("StrGeneric1");}
catch(Exception e){}


3.- in JSP
using StrGeneric1 whit value
AClass obj = new Aclass();
obj.setStrGeneric1 (StrGeneric1);

Listcc = obj.getListOfSelect(); //when ends 4.-

4.- the class AClass
db_Local <--- a SQL class

using code like:
java.sql.PreparedStatement pstmt= db_Local.Connection.prepareStatement ("select * from Table where StrGeneric1=?");
pstmt.setString (1,Value);
pstmt.executeUpdate();

--->return a List for example.

5.- JSP
iterate the list.
show data to client browser.

:thumbup: This is only like reference, there are many frameworks to do the job.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66153
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As Paul has said, this has no place in a JSP. The practice of putting Java code into a JSP has been discredited for 10 years now. 10 years! Any advice that has you put Java code into a JSP is bad advice.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!