aspose file tools*
The moose likes JSP and the fly likes JSP code is not working in jquery Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "JSP code is not working in jquery" Watch "JSP code is not working in jquery" New topic
Author

JSP code is not working in jquery

gupta pankaj
Greenhorn

Joined: Mar 06, 2013
Posts: 3
\\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++) {
\\Want to display the files and directories
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>
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61010
    
  65

JSP code has nothing much to do with jQuery. JSP executes on the server; jQuery on the client. All that matters is what is sent to the browser.

So rather than look at the server-side code, look at what is sent to the browser. Is it correct? Is it valid? What's different?

By the way, Java code in a JSP is a very poor and obsolete practice from 12 years ago. You should no longer be putting Java code in JSPs.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSP code is not working in jquery