0

Why is a null displayed in the first row?:-/
I want the first row to display the text value given in the textfield(actually i am getting the text value from database)
Any help??

<html>
    <head>
      
    </head>
    <body>
        <form name="form1">
            <input type="text" name="txtname">
            <input type="submit" value="Click here" name="Click"  onclick="fun(this.form)"/>
       
    </form>
    
    
      <script>
        function fun(form1)
        {
       var a='Hello';
        document.write('<center><table width="75%" border="1">'); 
         document.write('<tr align="center"><td>' + <% out.println(request.getParameter("txtname")); %> + '<\/td><td>' +a + '<\/td><\/tr>'); 
          document.write('<tr align="center"><td>' + a + '<\/td><td>' +a + '<\/td><\/tr>'); 
      document.write('<\/table><\/center>'); 
        }
       </script>
    </body>
</html>

****************
OUTPUT
    Null    Hello
    Hello   Hello
3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by javaAddict
0

Because this is null:

request.getParameter("txtname")

Try to learn first jsp before attempting such code. You need to use javascript.
And don't do that:

<% out.println(....); %>

Use <%= ....%> . It is the right way.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.