Note that there are some explanatory texts on larger screens.

plurals
  1. POJSP + Eclipse + TomCat: cannot be resolved to a type
    primarykey
    data
    text
    <p>I know this question has been asked a lot of times, but so far, none of the answers previously given have worked for me, here is my code:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;Programa&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;div&gt; Introduzca una palabra a buscar: &lt;input type="text" id="INPUT"&gt; &lt;%@ page import="java.net.URL" %&gt; &lt;%@ page import="com.google.gson.*" %&gt; &lt;%@ page import="java.net.URLEncoder" %&gt; &lt;%@ page import="java.io.InputStreamReader" %&gt; &lt;%@ page import="java.io.InputStream" %&gt; &lt;%@ page import="java.io.Reader" %&gt; &lt;%@ page import="javax.swing.*" %&gt; &lt;%@ page import="java.awt.event.*;" %&gt; &lt;%! int min(int a,int b) { return (a&gt;b)? b:a; } int edit_distance(String a,String b) { int n = a.length(), m = b.length(),costo; int[][] mat = new int[n+1][m+1]; for(int i=0;i&lt;=n;++i) mat[i][0] = i; for(int j=0;j&lt;=m;++j) mat[0][j] = j; for(int i=1;i&lt;=n;++i) { for(int j=1;j&lt;=m;++j) { costo = a.charAt(i-1) == b.charAt(j-1)? 1 : 0; mat[i][j] = min(min(mat[i-1][j] + 1,mat[i-1][j-1] + costo),mat[i][j-1] + 1); } } return mat[n][m]; } String resultados_de_la_busqueda(String search) { //Básicamente lo que hace esta función es devolverte una cadena con los resultados de la búsqueda StringBuffer RES = new StringBuffer("&lt;html&gt;"); String google = "http://ajax.googleapis.com/ajax/services/search/web?v=1.0&amp;q="; //El enlace para buscar en google String charset = "UTF-8"; URL url; Reader reader; try { url = new URL(google + URLEncoder.encode(search, charset)); try { reader = new InputStreamReader(url.openStream(), charset); GoogleResults results = new Gson().fromJson(reader, GoogleResults.class); for(int i=0;i&lt;3;++i) { RES.append(results.getResponseData().getResults().get(i).getTitle()); RES.append("&lt;br/&gt;"); RES.append("&lt;a href=\""); RES.append(results.getResponseData().getResults().get(i).getUrl()); RES.append("\"&gt;" + results.getResponseData().getResults().get(i).getUrl() + "&lt;/a&gt;"); RES.append("&lt;br/&gt;&lt;br/&gt;"); } } catch(Exception e) {} } catch(Exception e) {} return RES.toString(); } %&gt; &lt;% //Se supone que acá debo mostrar el resultado de la búsqueda... out.println(resultados_de_la_busqueda("taringa")); %&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>And here is the error I'm getting:</p> <pre><code>org.apache.jasper.JasperException: No se puede compilar la clase para JSP: Ha tenido lugar un error en la línea: 47 en el archivo jsp: /Programa.jsp GoogleResults cannot be resolved to a type Gson cannot be resolved to a type </code></pre> <p>Any idea on what is causing the problem?</p> <p>Edit 1:</p> <p>This is the GoogleResults class:</p> <pre><code>import java.util.List; public class GoogleResults { private ResponseData responseData; public ResponseData getResponseData() { return responseData; } public void setResponseData(ResponseData responseData) { this.responseData = responseData; } public String toString() { return "ResponseData[" + responseData + "]"; } static class ResponseData { private List&lt;Result&gt; results; public List&lt;Result&gt; getResults() { return results; } public void setResults(List&lt;Result&gt; results) { this.results = results; } public String toString() { return "Results[" + results + "]"; } } static class Result { private String url; private String title; public String getUrl() { return url; } public String getTitle() { return title; } public void setUrl(String url) { this.url = url; } public void setTitle(String title) { this.title = title; } public String toString() { return "Result[url:" + url +",title:" + title + "]"; } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload