Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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>
Posted
Updated 29-Mar-13 21:23pm
v2

1 solution

Hello,

First of all remove following lines. from doPost method of your servlet.
Java
PrintWriter writer = response.getWriter();
writer.println("<html>");
writer.println("<head><title>checking Servlet</title></head>");
writer.println("<body>check check ?</body>");
writer.println("</html>");

Secondly change the for loop as shown below. Although JSTL will find the variable, it better if you specify the scope explicitly.
HTML
<c:foreach items="${requestScope.resultss}" var="rowObject">

Please also change the code in doPost as follows.
Java
RequestDispatcher rd = null;
    try {
            rd = request.getRequestDispatcher("/wow.jsp");
 
    } catch (ServletException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch blockl
        e.printStackTrace();
    }
    request.setAttribute("resultss", resultss); // Will be available as ${resultss} in JSP
    rd.forward(request, response);

Regards,
 
Share this answer
 
v3
Comments
Member 3369145 30-Mar-13 1:41am    
thanks, i changed it but in wow.jsp ,it is showing error
----------------------------
- Undefined attribute name
"xmlns:c"


and in server trace the msg is:
---------------------------------
Servlet.service() for servlet [jsp] in context with path [/finalproject] threw exception [/wow.jsp(18,70) The attribute prefix xmlns does not correspond to any imported tag library] with root cause
org.apache.jasper.JasperException: /wow.jsp(18,70) The attribute prefix xmlns does not correspond to any imported tag library
Prasad Khandekar 30-Mar-13 3:17am    
I have updated the solution. Please remove the xmlns:c attribute and it's value. I don't know how it appeared in there. It should fix the problem. Also remove very first line from doPost which reads as response.setContentType("text/html");.

Regards,
Member 3369145 30-Mar-13 3:41am    
i ave changed according to u, but not working, it show nathing in wow.jsp -----------
i have post my changed code also
Prasad Khandekar 30-Mar-13 9:59am    
Updated code does not really reflect the suggested changes. But are you sure that results gets populated with 1 or more records? If you do a view source do you see an empty table? (<table></table>).
Member 3369145 30-Mar-13 10:35am    
yes i did debug and it is populating data. but not passing the data in jsp

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


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