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 2 of 2

Thread: Newbie needs help in simple servlet program

  1. #1
    Junior Member
    Join Date
    Dec 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Newbie needs help in simple servlet program

    i'm a newbie so help me out here in simple program

    java code:

    import java.io.* ;
    import javax.servlet.* ;
    import javax.servlet.http.* ;


    public class color extends HttpServlet
    {

    public void doGet(HttpServletRequest req, HttpServletResponse res)
    throws ServletException, IOException {
    res.setContentType("text/html");
    PrintWriter pw = res.getWriter();
    String color = req.getParameter("color") ;
    pw.println("The color is" + color) ;
    pw.println("<html>") ;
    pw.println("<body bgcolor = "color">") ;
    pw.println("</body>") ;
    pw.println("</html>") ;
    }
    }


    i want to display the color in background along with the text "the color is" whenever appropriate color
    is selected but whenever i compile this program i get 1 error as follows
    ' ) ' is expected at line pw.println("<body bgcolor = "color">") ;
    where am i supposed to put that bracket?
    thanks in advance


  2. #2
    Junior Member
    Join Date
    Dec 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile Re: Newbie needs help in simple servlet program

    Hi,

    as you want to have the color value to be displayed then you need to replace with below statement

    pw.println("<body bgcolor = \""+color+"\">") ;

    Thanks,
    Raghu.

Similar Threads

  1. Simple Program for Cash
    By javastudent in forum Paid Java Projects
    Replies: 9
    Last Post: December 1st, 2009, 07:25 AM
  2. Error of data types and type casting in java program
    By chronoz13 in forum What's Wrong With My Code?
    Replies: 8
    Last Post: September 2nd, 2009, 11:22 AM
  3. PLEASE HELP!!!! simple java program...
    By parvez07 in forum Object Oriented Programming
    Replies: 5
    Last Post: August 26th, 2009, 07:38 AM
  4. help with simple java program
    By parvez07 in forum Java Theory & Questions
    Replies: 4
    Last Post: August 25th, 2009, 08:19 AM
  5. Someone please help me write a simple program!!!
    By ocean123 in forum Loops & Control Statements
    Replies: 3
    Last Post: June 14th, 2009, 10:46 PM