ajos 283
Contributor
hi frnds,
im doing some db related operations in my web project,im using mysql 5.0,i have the following piece of code in my action class- -
for(resultset = statement.executeQuery(s2); resultset.next();)
-
{
-
s10 = resultset.getString(1);
-
s11 = resultset.getString(2);
-
s12 = resultset.getString(3);
-
}
-
resultset.close();
how do i retrieve the result of s10,s11,s12 in my jsp page?? wat changes do i have to do in my code??(i.e form bean and jsp page)??
wud appreciate ur thoughts...thanx in advance..
regards,
ajos
13 14565
hi frnds,
im doing some db related operations in my web project,im using mysql 5.0,i have the following piece of code in my action class- -
for(resultset = statement.executeQuery(s2); resultset.next();)
-
{
-
s10 = resultset.getString(1);
-
s11 = resultset.getString(2);
-
s12 = resultset.getString(3);
-
}
-
resultset.close();
how do i retrieve the result of s10,s11,s12 in my jsp page?? wat changes do i have to do in my code??(i.e form bean and jsp page)??
wud appreciate ur thoughts...thanx in advance..
regards,
ajos
You can write that same code in a JSP. Or extract the results in some other class and then send the results to the JSP as an attribute.
ajos 283
Contributor
You can write that same code in a JSP. Or extract the results in some other class and then send the results to the JSP as an attribute.
hi r035198x,
thanx for ur reply yet again.....ive opted for the 2nd solution i.e using setAttribute
this is wat ive done- -
s10 = resultset.getString(1);
-
httpservletrequest.setAttribute("s10", s10);
-
s11 = resultset.getString(2);
-
httpservletrequest.setAttribute("s11", s11);
-
s12 = resultset.getString(3);
-
httpservletrequest.setAttribute("s12", s12);
-
-
is this the right way?
how do i call this in my jsp page--->which is like this
[HTML]<font face="Tahoma">"+ s11 +"</font>[/HTML]
[HTML]<font face="Tahoma">" +s12+ "</font>[/HTML]
regards,
ajos
hi r035198x,
thanx for ur reply yet again.....ive opted for the 2nd solution i.e using setAttribute
this is wat ive done- -
s10 = resultset.getString(1);
-
httpservletrequest.setAttribute("s10", s10);
-
s11 = resultset.getString(2);
-
httpservletrequest.setAttribute("s11", s11);
-
s12 = resultset.getString(3);
-
httpservletrequest.setAttribute("s12", s12);
-
-
is this the right way?
how do i call this in my jsp page--->which is like this
[HTML]<font face="Tahoma">"+ s11 +"</font>[/HTML]
[HTML]<font face="Tahoma">" +s12+ "</font>[/HTML]
regards,
ajos
- <%
-
String s10 = (String)request.getAttribute("s10");
-
%>
ajos 283
Contributor - <%
-
String s10 = (String)request.getAttribute("s10");
-
%>
hi,
im getting the values of that particular columns as null....this is wat i did
<%String s11=(String)request.getAttribute("s11"); %>
<font face="Tahoma"> <%=s11 %> </font>
i think this is right...wats wrong with this????
hi,
im getting the values of that particular columns as null....this is wat i did
i think this is right...wats wrong with this????
How did you call the JSP in the code?
ajos 283
Contributor
How did you call the JSP in the code?
ok this is how i called in the jsp page--> -
-
<%String s11=(String)request.getAttribute("s11"); %>
-
<font face="Tahoma"> <%=s11 %> </font>
-
-
where <%=s11%> is the values that will be displayed...
regards,
ajos
ok this is how i called in the jsp page--> -
-
<%String s11=(String)request.getAttribute("s11"); %>
-
<font face="Tahoma"> <%=s11 %> </font>
-
-
where <%=s11%> is the values that will be displayed...
regards,
ajos
No that's not what I'm asking. Are you calling the JSP from a servlet? You should be. Otherwise if you are not using servlets then you should use the other option I talked about earlier.
ajos 283
Contributor
No that's not what I'm asking. Are you calling the JSP from a servlet? You should be. Otherwise if you are not using servlets then you should use the other option I talked about earlier.
my code,--> -
for(resultset = statement.executeQuery(s2); resultset.next();)
-
{
-
s10 = resultset.getString(1);
-
httpservletrequest.setAttribute("s10", s10);
-
s11 = resultset.getString(2);
-
httpservletrequest.setAttribute("s11", s11);
-
s12 = resultset.getString(3);
-
httpservletrequest.setAttribute("s12", s12);
-
}
-
this is in the action class...
im calling getAttribute in my jsp page
my code,--> -
for(resultset = statement.executeQuery(s2); resultset.next();)
-
{
-
s10 = resultset.getString(1);
-
httpservletrequest.setAttribute("s10", s10);
-
s11 = resultset.getString(2);
-
httpservletrequest.setAttribute("s11", s11);
-
s12 = resultset.getString(3);
-
httpservletrequest.setAttribute("s12", s12);
-
}
-
this is in the action class...
im calling getAttribute in my jsp page
You should call the JSP from the code using - request.getRequestDispatcher("JSPPathAndName.jsp").include(request, response);
That way you pass the attributes to the JSP as well. You can't call this JSP by just double clicking it because then it wont have the attributes set.
ajos 283
Contributor
That way you pass the attributes to the JSP as well. You can't call this JSP by just double clicking it because then it wont have the attributes set.
You should call the JSP from the code using - request.getRequestDispatcher("JSPPathAndName.jsp").include(request, response);
im already forwarding the control to the jsp page using - return(mapping.findForward("pathname"));
the method u mentioned above,wud had gone well if i use servlets...but - return(mapping.findForward("pathname"));
also does wat RequestDispatcher does..
i better check my database records coz in the form bean ive set the value as null eg-private xyz=null; and since that is printing i think its ok...correct me if im wrong...
regards,
ajos
im already forwarding the control to the jsp page using - return(mapping.findForward("pathname"));
the method u mentioned above,wud had gone well if i use servlets...but - return(mapping.findForward("pathname"));
also does wat RequestDispatcher does..
i better check my database records coz in the form bean ive set the value as null eg-private xyz=null; and since that is printing i think its ok...correct me if im wrong...
regards,
ajos
Yep check with println statements to see that you are forwarding non null values in the first place.
P.S I'm going to have to move this to the Java forum as it doesn;t have much to do with MySQL
ajos 283
Contributor
Yep check with println statements to see that you are forwarding non null values in the first place.
P.S I'm going to have to move this to the Java forum as it doesn;t have much to do with MySQL
hi r035198x,
i think its right.i checked the database,and to my disbelief the records entered in the table wasnt enough hence the queries requirement wasnt matching....
thanx for the help yet again.....(i think this will never stop!!!)
regards,
ajos
hi r035198x,
i think its right.i checked the database,and to my disbelief the records entered in the table wasnt enough hence the queries requirement wasnt matching....
thanx for the help yet again.....(i think this will never stop!!!)
regards,
ajos
What will never stop?
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: cliff |
last post by:
I am in the process of developing an application and would like to hide the
query strings in the URLs. I want to POST data to a page then validate the
data. If there is an error I have to send data...
|
by: aniket_sp |
last post by:
i am using a data adapter and a dataset for filling and retrieving data
into .mdb database.
following is the code.....
for the form load event
Dim dc(0) As DataColumn
Try
If...
|
by: Jakob Petersen |
last post by:
Hi,
I need to increase the speed when retrieving data from a hosted SQL Server into VBA. I'm using simple SELECT statements.
How important is the speed of my Internet connection? (I have...
|
by: DC01 |
last post by:
I have added a new measure successfully into the normal cube. I then add it to the virtual cube and reprocess all cubes. I can browse the normal cube successfully. Then when I try and browse the...
|
by: hanusoft |
last post by:
This is an example of Inserting and Retrieving data from xml file.
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
...
| |
by: hanusoft |
last post by:
This is an example of Inserting and Retrieving data from xml file.
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
...
|
by: smartin |
last post by:
Hi,
I'm having problem retrieving data from an SQL stored procedure. I tried debugging but it wont give a the reason for the error. it just throws an exception after executing cmd.ExecuteNonQuery...
|
by: ADezii |
last post by:
Last Tip, we demonstrated the technique for retrieving data from a DAO Recordset, and placing it into a 2-dimensional Array using the GetRows() Method. This week, we will cover the same exact Method...
|
by: vikas1111 |
last post by:
Hi All
Can anyone give me an idea to solve the problem.. My Problem is ,, I want to Retrieving data from database and displaying in textbox... If anybody have link of some good tutorial on...
|
by: splendid9 |
last post by:
Problem in retrieving data from a XML file.......this is my code-
protected void Page_Load(object sender, EventArgs e)
{
DataSet ds = new DataSet();
...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |