mardi 29 avril 2014

Converte value of JSP to java string


Vote count:

0




I want to have search so whenever the user write the query and click on submit. The process function of the java class serverSearch gives the query and return the result. Unfortunately I could not find a way to do it correctly, what should I do?


I wrote the follwing code but I always get the null value.



<%@ page import="test.serverSearch" %>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>

<%
String queryInJSP=request.getParameter("Query");
%>

<html>

<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js" ></script>

<title>Information Retrieval WS1314: Search Demo</title>

</head>

<body>
<form name="frm" method="get" action="textInput.jsp">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="22%">&nbsp;</td>
<td width="78%">&nbsp;</td>
</tr>
<tr>
<td>Query </td>
<td><input type="text" name="query"></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type="submit" name="submit" value="Submit"></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>

</table>
</form>
<jsp:useBean id="link" scope="application" class = "test.SearchServerMain" />
<% SearchServer ts=new SearchServer();
ts.getInput(queryInJSP);
%>

<script type="text/javascript">



/* $( "#a" ).change(function() {
alert($("#a").text());
});
*/
$('#a').keyup('input', function() {
$("#dd").text($("#a").val());
});

</script>
</body>

</html>


java code is simple code



public class SearchServer {

public void getInput(String query){
System.out.println(query);
}
}


asked 33 secs ago






Aucun commentaire:

Enregistrer un commentaire