Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: JSP tags

  1. #1
    Junior Member
    Join Date
    Jun 2011
    Posts
    10
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default JSP tags

    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
    HTML Code:
    <tr><th> you name: <%fname%> </th></tr>

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


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: JSP tags

    If you want to print, use the reference to the output stream
    out.println(fname);

  3. The Following User Says Thank You to copeg For This Useful Post:

    mithcool (July 12th, 2011)

  4. #3
    Junior Member
    Join Date
    Jun 2011
    Posts
    10
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: JSP tags

    out.println(fname); or it can be <%=fname%>
    thanks anyways

Similar Threads

  1. Printing name tags from a csv file
    By infoman in forum Java Theory & Questions
    Replies: 8
    Last Post: January 25th, 2011, 05:20 AM
  2. Implementing HTML tags in Java Source Code
    By bookface in forum Java Theory & Questions
    Replies: 4
    Last Post: March 19th, 2010, 09:29 PM
  3. Help with html tags in java
    By peliukasss in forum Member Introductions
    Replies: 0
    Last Post: February 2nd, 2010, 06:47 AM
  4. [SOLVED] Java code to embedding xml tags at start and end of file
    By John in forum File I/O & Other I/O Streams
    Replies: 3
    Last Post: April 30th, 2009, 03:02 PM
  5. [SOLVED] Parsing ID3 tags from mp3
    By John in forum Java Theory & Questions
    Replies: 14
    Last Post: April 16th, 2009, 01:36 PM

Tags for this Thread