Click here to Skip to main content
15,889,852 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
XML
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js">
       </script>

       <script>
           //$(document).ready(function(){

           //   $("#dir1").click(function(){
           //  $("#dir1").focusout(function(){
           var str1;
           $(document).ready(function(){
               $("#dir1").focusout(function(){
                   $(".test").hide();
                   alert("Value: " + $("#dir1").val());
           <%
                String str1 = "d:\\";
                File f1 = new File(str1);
                File[] contents = f1.listFiles();
                for (int j = 0; j < contents.length; j++) {

                    if (contents[j].isDirectory()) {

                        out.println("Directory : " + contents[j].getName() + "<br/>");
                    }
                    if (contents[j].isFile()) {
                        out.println("Files :" + contents[j].getName() + "<br/>");
                    }

                }
           %>



                   });
               });
       </script>

Not Showing any output?? Help me
Posted
Updated 6-Mar-13 1:45am
v2

1 solution

It seems like coding/syntax error. Once your JSP page gets parsed, and contents reaches to client side, it will show something like this -
JavaScript
//$(document).ready(function(){

//   $("#dir1").click(function(){
//  $("#dir1").focusout(function(){
var str1;
$(document).ready(function(){
    $("#dir1").focusout(function(){
        $(".test").hide();
        alert("Value: " + $("#dir1").val());

        Directory : dir1<br />
        Files : my file1.doc<br />
        Files : my file2.txt<br />
        Files : my file3.xls<br />
        Directory : dir2<br />
        Files : my file4.doc<br />
        Files : my file5.doc<br />
        Files : my file6.doc<br />
        Files : my file7.doc<br />
        Files : my file8.doc<br />
    });
});


As you see, the output data from your JSP is not properly quoted, and it doesn't make any sense.

Simply check the source of your generated HTML page and you will clearly see the problem.

Regards,
Niral Soni
 
Share this answer
 
Comments
lalitk369 6-Mar-13 11:58am    
thnks sir for reply,,

Sori but i am not able to understand the problem.
when i miss the jsp code i.e<% all data %> then it work fine, but when i enter the jsp code in it it does not give any output. soo help me out?
This is the whole program:


<%@page import="java.io.File"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js">
</script>

<script>
var str1;
$(document).ready(function(){
$("#dir1").focusout(function(){
$(".test").hide();
alert("Value: " + $("#dir1").val());
<%
String str1 = "d:\\";
File f1 = new File(str1);
File[] contents = f1.listFiles();
for (int j = 0; j < contents.length; j++) {

if (contents[j].isDirectory()) {

out.println("Directory : " + contents[j].getName() + "<br/>");
}
if (contents[j].isFile()) {
out.println("Files :" + contents[j].getName() + "<br/>");
}

}
%>



});
});
</script>
<title>JSP Page</title>

</head>
<body>
<input type="text" name="dir1" id="dir1"/>

</body>
</html>
Niral Soni 7-Mar-13 9:16am    
And what exactly you want to achieve with this piece of code ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900