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

Recommended Answers

All 2 Replies

Looks like javascript. This is a java forum. They are different.

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.

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.