//servlet

if(rs.next())
            {
                            String s1 = rs.getString("pname");
		            String s2 = rs.getString("remarks");
		            String s3= rs.getString("cnt");
		            String s4 = rs.getString("bsponsor");
		            String s5 = rs.getString("bprowner");
		            String s6 = rs.getString("priority");
                            list.add(s1);
                            list.add(s2);
                            list.add(s3);
                            list.add(s4);
                            list.add(s5);
                            list.add(s6);
            }

            
                session.setAttribute("list",list);
                RequestDispatcher rd=getServletContext().getRequestDispatcher("/project.jsp");
                rd.forward(request,response);

//jsp page

<%
ArrayList arr = (ArrayList) session.getAttribute("list");

String myString="";


if(arr.isEmpty()==false)
{
for(int i = 0; i < arr.size(); i++)
{
myString = (String)arr.get(i);
}
}
else
{
System.out.println("Array is empty");
}
%>
<tr>

<td>
project Name
</td>
<td>
    <input type="text" name="pname" id="pname" size="25" value="<%=myString%>" disabled>
</td>

</tr>
<tr>
<td>
Description/Remarks
</td>
<td><input type="text" name="remarks" size="25" value="<%=myString%>"  disabled>
</td>
</tr>

servlet is working fine but i am not getting desired output in jsp page.i have five fields and my control goes to servlet ,it retrieves the data from the database and redirect the control to jsp page.now i want to show values of 5 fields into respective text boxes. please help

read up on JSTL, stop using Java code in JSP.

And read your code. You're iterating through the entire List, and only afterwards printing a single value.
Hardly surprising you're not getting the result you expect.

Scriptlets are bad because :

1-EL is more terse and readable.
2-scriptlets are not re-usable software components.
3-java and HTML should be separated as much as possible. Business logic does not belong in the presentation layer, and should be encapsulated in javabeans instead, which are re-usable.
4-scriptlets cannot use inheritance or composition
5-debugging scriptlets can be painful, if an exception is thrown halfway you might just get a blank page. So check the logs... Scriptlets are also a nightmare to maintain. I have "inherited" a project at my current workplace with more java code in JSPs than in .class files and its SPAGHETTI time. . . 
6-scriptlets are not unit-testable.
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.