linda22
asked on
Use of Java beans
My ques is a very basic one.
What is the use of beans in JSP.
If I make a form in html and submit it to a jsp page where I receive it using
request.getParameter("var1 ");
and insert it into the database.
The other method is to send it to a bean using
<jsp:setProperty name="TheBean" property="*" />
Which method is better and why.
The same thing i'd like to know when retreiving data.
I retreive the data in jsp page and display it in HTML table
<TD><%=rs.getString("col1" )%></TD>
The second method could be to retreive the data in the bean and concatenate it to a variable
showData=showData+"<td>";
showData=showData+col1;
showData=showData+"</td>";
And then fetch the variable in the JSP page and print it there.
Which method of the 2 is better. Moreover when I use the method of beans to retreive data it makes the application very slow. What could be the reason for that?
Kindly Suggest
What is the use of beans in JSP.
If I make a form in html and submit it to a jsp page where I receive it using
request.getParameter("var1
and insert it into the database.
The other method is to send it to a bean using
<jsp:setProperty name="TheBean" property="*" />
Which method is better and why.
The same thing i'd like to know when retreiving data.
I retreive the data in jsp page and display it in HTML table
<TD><%=rs.getString("col1"
The second method could be to retreive the data in the bean and concatenate it to a variable
showData=showData+"<td>";
showData=showData+col1;
showData=showData+"</td>";
And then fetch the variable in the JSP page and print it there.
Which method of the 2 is better. Moreover when I use the method of beans to retreive data it makes the application very slow. What could be the reason for that?
Kindly Suggest
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Points increased to 240 from 190
>>What sort of code should be placed in the JSP page?
Normally, i will put iteration or looping code in the JSP, for example :
<%
for( int i = 0 ; i < thisList.size(); i ++ )
{
%>
<html tag>
<%
}
%>
>>Can there be any situation when make making a connection and performimg DML or select operations be done in the JSP page or they should always be done in the bean.
Basically, In MVC model, JSP page plays the Viewer role, and the logic should be seperated in the java beans.
Normally, i will put iteration or looping code in the JSP, for example :
<%
for( int i = 0 ; i < thisList.size(); i ++ )
{
%>
<html tag>
<%
}
%>
>>Can there be any situation when make making a connection and performimg DML or select operations be done in the JSP page or they should always be done in the bean.
Basically, In MVC model, JSP page plays the Viewer role, and the logic should be seperated in the java beans.
ASKER
Thank You so much
ASKER
Another thing i want to know. What sort of code should be placed in the JSP page?
Should it be only calls to methods in java beans and some HTML or something else?
Can there be any situation when make making a connection and performimg DML or select operations be done in the JSP page or they should always be done in the bean.