<%
String str_id = request.getParemeter("id");
// check here to make sure str_id is not null or non empty
...
String str_sql="select * from Users where UserId="+str_id;
// execute your query here
%>
Hope this helps,
Anirban
Abhinav Nath wrote:
>
> Hi,
> Can any one tell how do I pass parameterized query using JSP
> I'm new tto JSP development and was developing with ASP.
>
> For example
> If I have a QueryString as http://localhost/db2.jasp?id=23
>
> Now I want to store this parameter (id)in a variable
> and Query the dtabase.
>
> Sql="select * from Users where UserId=<%=request.getParemeter("id")%>"
> isgiving error and if store it in a variable then also It's
> giving error
>
> like
> <%! int var %>
> <% var = request.getParaneter("id")%>
>
> Sql="selecct * from Users where User_Id = var "
>
> In this case it's taking var as a string.
>
> Please can some one send sample codes of doing this thing by passing the
> parameter both as aQueryString and by Forms.
>
> Thanks in Advance
>
> Abhinav
>
> ______________________________________________________
> Get Your Private, Free Email at http://www.hotmail.com
>
> ===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
> FAQs on JSP can be found at:
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.html
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html