I only wanted to print the value in the string variable fname but somehow am not able to use the jsp tags effectively.

<%@page language="java" import="java.util.*" %>
<%
Cookie[] c= request.getCookies();
if(c==null)
    {
    response.sendRedirect("index.jsp");
}
else
    {
    for (int i=0; i<c.length; i++)
    {
        if(c[i].getName().equals("Cuname"))
            {
            try{
            Connection con=null;
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            con=DriverManager.getConnection("jdbc:odbc:SQL","sa","mith1234");
            String select="select * from sign_up where u_name=\'"+c[i].getValue()+"\'";
            PreparedStatement ps= con.prepareStatement(select);
            ResultSet rs= ps.executeQuery();
            if (rs.next()== true)
               {
                String fname= rs.getString(1);
                out.println(fname);
           }
            }
catch(Exception e)
        {
    out.println(e);
}
    }
    }
    }
%>

Now here i want to print the fname i.e. string

<tr><th> you name: <%fname%> </th></tr>

Some problem with the tag i am using i suppose.... Help me

Recommended Answers

All 5 Replies

Throw away the scriplet and read the JEE6 tutorials and learn how to do this stuff right.

Thanks for your kind help friend.... but if you can just provide me the link of the particular topic am looking for....

no I didnt get what you are trying to say??? if u can just tell me what is wrong with the tags am using and probably fix it..... thanks

What tags? You are not using any tags. You are using alot of scriptlets, of which you should not be using any. And, when someone is going in the completely wrong direction all you can do is turn them around, so go read that tutorial.

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.