Click here to Skip to main content
15,897,090 members

not showing data from servlet to jsp , there is no error also

Member 3369145 asked:

Open original thread
stack trace:
--------------------------------------------------------------------------------------------
Mar 29, 2013 10:03:46 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/lib/jvm/java-6-openjdk-i386/jre/lib/i386/client:/usr/lib/jvm/java-6-openjdk-i386/jre/lib/i386:/usr/lib/jvm/java-6-openjdk-i386/jre/../lib/i386:/usr/lib/jvm/java-6-openjdk-i386/jre/lib/i386/client:/usr/lib/jvm/java-6-openjdk-i386/jre/lib/i386::/usr/java/packages/lib/i386:/usr/lib/i386-linux-gnu/jni:/lib/i386-linux-gnu:/usr/lib/i386-linux-gnu:/usr/lib/jni:/lib:/usr/lib
Mar 29, 2013 10:03:46 PM org.apache.coyote.AbstractProtocolHandler init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Mar 29, 2013 10:03:46 PM org.apache.coyote.AbstractProtocolHandler init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Mar 29, 2013 10:03:46 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 946 ms
Mar 29, 2013 10:03:46 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Mar 29, 2013 10:03:46 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.12
Mar 29, 2013 10:03:46 PM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor finalproject.xml from /home/ubuntu/tomcat/conf/Catalina/localhost
Mar 29, 2013 10:03:46 PM org.apache.catalina.startup.SetContextPropertiesRule begin
WARNING: [SetContextPropertiesRule]{Context} Setting property 'source' to 'org.eclipse.jst.jee.server:finalproject' did not find a matching property.
Mar 29, 2013 10:03:48 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory examples
Mar 29, 2013 10:03:48 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/core_rt is already defined
Mar 29, 2013 10:03:48 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/core is already defined
Mar 29, 2013 10:03:48 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/core is already defined
Mar 29, 2013 10:03:48 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/fmt_rt is already defined
Mar 29, 2013 10:03:48 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/fmt is already defined
Mar 29, 2013 10:03:48 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/fmt is already defined
Mar 29, 2013 10:03:48 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/functions is already defined
Mar 29, 2013 10:03:48 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://jakarta.apache.org/taglibs/standard/permittedTaglibs is already defined
Mar 29, 2013 10:03:48 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://jakarta.apache.org/taglibs/standard/scriptfree is already defined
Mar 29, 2013 10:03:48 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/sql_rt is already defined
Mar 29, 2013 10:03:48 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/sql is already defined
Mar 29, 2013 10:03:48 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/sql is already defined
Mar 29, 2013 10:03:48 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/xml_rt is already defined
Mar 29, 2013 10:03:48 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/xml is already defined
Mar 29, 2013 10:03:48 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/xml is already defined
Mar 29, 2013 10:03:48 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
Mar 29, 2013 10:03:48 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
Mar 29, 2013 10:03:48 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory ROOT
Mar 29, 2013 10:03:48 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory host-manager
Mar 29, 2013 10:03:48 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory manager
Mar 29, 2013 10:03:48 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory docs
Mar 29, 2013 10:03:48 PM org.apache.coyote.AbstractProtocolHandler start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Mar 29, 2013 10:03:48 PM org.apache.coyote.AbstractProtocolHandler start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Mar 29, 2013 10:03:48 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 1877 m

------------------------------------------------------------------------------------------

servlet:
____________
Java
package finalpackage;

import java.util.*;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.hp.hpl.jena.query.QueryExecution;
import com.hp.hpl.jena.query.QueryExecutionFactory;
import com.hp.hpl.jena.query.QueryFactory;
import com.hp.hpl.jena.query.QuerySolution;
import com.hp.hpl.jena.query.ResultSetFormatter;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.util.FileManager;

/**
 * Servlet implementation class smartservlet
 */
@WebServlet("/smartservlet/")
//@webservlet(urlPatterns = {"/smartservlet/*"})
public class smartservlet extends HttpServlet {
    private static final long serialVersionUID = 1L;
    public static final String MY_FOAF_FILE = "//home/ubuntu/indoor.rdf";

    /**
     * @see HttpServlet#HttpServlet()
     */
    public smartservlet() {
        super();
        // TODO Auto-generated constructor stub
    }

    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        doPost(request, response);
    }

    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        // TODO Auto-generated method stub
        response.setContentType("text/html");
        // TODO Auto-generated method stub
        PrintWriter writer = response.getWriter();
        writer.println("<html>");
        writer.println("<head><title>checking Servlet</title></head>");
        writer.println("<body>check check ?</body>");
        writer.println("</html>");
            
        Model model = ModelFactory.createDefaultModel();            

        FileManager.get().readModel(model,MY_FOAF_FILE);
        model.read(new File(MY_FOAF_FILE).toURI().toString());
        String queryString =  "SELECT ?predicate ?object   WHERE {?subject ?predicate ?object .}";  

        com.hp.hpl.jena.query.Query query = QueryFactory.create(queryString);
        QueryExecution qe = QueryExecutionFactory.create(query, model);

        com.hp.hpl.jena.query.ResultSet results = qe.execSelect();
      
        ResultSetFormatter.out(System.out, results);

        List<rowobject> resultss = new ArrayList<rowobject>();

        while ( results.hasNext()) {
            System.out.println("check 1");
            RowObject result = new RowObject();
            QuerySolution binding = results.nextSolution();
            result.setName(binding.get("object").toString());
            resultss.add(result);
        }

        String dbs="ame";
        request.setAttribute("resultss", resultss); // Will be available as ${results} in JSP
        //  request.setAttribute("dbs", dbs); // Will be available as ${results} in JSP
        try {
            request.getRequestDispatcher("/wow.jsp").forward(request, response);

            //RequestDispatcher RequetsDispatcherObj =request.getRequestDispatcher("/wow.jsp");
            //RequetsDispatcherObj.forward(request, response);
        } catch (ServletException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch blockl
            e.printStackTrace();
        }
    }
}</pre?
jsp page  to show data from servlet:
-------------------------------
<pre lang="xml"><%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>

   <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
   <%@ page isELIgnored="false" %>
 <%@ page import="finalpackage.smartservlet" %>
<%@ page import="finalpackage.RowObject"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<table>
    <c:forEach items="${resultss}" var="rowObject">
        <tr>
        <td>${rowObject.getName()}</td>
        <td>${rowObject.getSymbol()}</td>
        <td>${rowObject.getNumber()}</td>

        </tr>
    </c:forEach>
</table>

</body>
</html>
Tags: Javascript, Servlet

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



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