-
Simple Search Engine
Im having a problem with my search engine, it does not display the value in the web browser. What i want to do is to make a search engine without using sql connection which is i dont know how to do it. i have a 2 pages The view(html,jsp) and the controller(servlet). What i want is using the value that i set it in the codes will be displayed in view when searching.
(studentSearch.jsp)
Code:
<%@page import="com.sun.org.apache.xerces.internal.xs.StringList"%>
<%@page import="java.util.*"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!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>Search Student</title>
</head>
<body>
<form id="search" action="StudentSearchController" method="post">
<table width="28%" >
<tr>
<td>Product Code</td>
<td><label>
<input type="text" name="pro_code" id="pro_code" />
</label></td>
</tr>
<tr>
<td>Name</td>
<td><label>
<input type="text" name="name" id="name" />
</label></td>
</tr>
<tr>
<td>Price</td>
<td><label>
<input type="text" name="price" id="price" />
</label></td>
</tr>
<tr>
<td><label>
<input type="submit" name="search_button" id="search_button" value="Search" />
</label></td>
</tr>
</table>
</form>
<table width="40%" style="border:1px solid #000000;">
<tr>
<td colspan=8 align="center" style="background-color:ffeeff"><b>Product Record</b></td>
</tr>
<tr style="background-color:efefef;">
</table>
<table width="40%" border="1">
<tr style="background-color:efefef;">
<td id="pro_code"><b>Product Code</b></td>
<td id="name"><b>Name</b></td>
<td id="price"><b>Price</b></td>
</tr>
</table>
<%
int count=0;
String color = "blue";
if(request.getAttribute("proList")!=null) {
StringList proList = (StringList)request.getAttribute("al");
Iterator itr = proList.iterator();
while(itr.hasNext())
{
if((count%2)==0)
{
color="yellow";
}
else
{
color="brown";
}
count++;
ArrayList al = (ArrayList)itr.next();
%>
<tr style="background-color:<%=color%>;">
<td><%=proList.get(0)%></td>
<td><%=proList.get(1)%></td>
<td><%=proList.get(2)%></td>
<%
}
}
%>
</body>
</html>
(StudentSearchController.java)
Code:
package controller;
import java.util.*;
import java.awt.*;
import java.io.IOException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet("/StudentSearchController")
public class StudentSearchController extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
try{
String pcode = request.getParameter("pro_code");
String pname = request.getParameter("name");
String pprice = request.getParameter("price");
//parameter
ArrayList al = null;
ArrayList pro_list = new ArrayList();
al = new ArrayList();
al.add("1");
al.add("a");
al.add("1");
pro_list.addAll(al);
//
request.setAttribute("pro_code", pcode);
request.setAttribute("name", pname);
request.setAttribute("price",pprice);
RequestDispatcher rd = request.getRequestDispatcher("/studentSearch.jsp");
rd.forward(request, response);
} catch (Exception e) {
e.printStackTrace();
}
}
}
Code:
Mar 15, 2012 1:34:13 AM 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: C:\Program Files\Java\jre7\bin;C:\windows\Sun\Java\bin;C:\windows\system32;C:\windows;C:/Program Files/Java/jdk1.6.0_27/bin/../jre/bin/client;C:/Program Files/Java/jdk1.6.0_27/bin/../jre/bin;C:/Program Files/Java/jdk1.6.0_27/bin/../jre/lib/i386;C:\oraclexe\app\oracle\product\11.2.0\server\bin;C:\oraclexe\app\oracle\product\11.2.0\server\bin;C:\Program Files\Java\jdk1.6.0_27\bin;C:\Program Files\NVIDIA Corporation\PhysX\Common;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Toshiba\Bluetooth Toshiba Stack\sys\;c:\Program Files\Microsoft SQL Server\90\Tools\binn\;C:\Program Files\QuickTime\QTSystem\;C:\Program Files\TortoiseSVN\bin;C:\Program Files\Java\jdk1.6.0_27\bin;%POSTGRES_HOME%\bin;C:\grails\bin;C:\groovy-1.8.6\bin;C:\oraclexe\app\oracle\product\11.2.0\server\\bin;C:\Program Files\Java\jdk1.6.0_27\bin;C:\Program Files\Java\jdk1.6.0_27\jre\bin;C:\Program Files\Java\jdk1.6.0_27\jre\bin\client;\bin;C:\Users\cire\Desktop\eclipse;;.
Mar 15, 2012 1:34:13 AM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:Quiz 1' did not find a matching property.
Mar 15, 2012 1:34:13 AM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:PointOfSales' did not find a matching property.
Mar 15, 2012 1:34:13 AM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:Customer' did not find a matching property.
Mar 15, 2012 1:34:13 AM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:Inventory' did not find a matching property.
Mar 15, 2012 1:34:13 AM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:retailPOS' did not find a matching property.
Mar 15, 2012 1:34:13 AM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:DemoProject' did not find a matching property.
Mar 15, 2012 1:34:13 AM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:Midterm' did not find a matching property.
Mar 15, 2012 1:34:13 AM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:retail' did not find a matching property.
Mar 15, 2012 1:34:13 AM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:SampleMidterm' did not find a matching property.
Mar 15, 2012 1:34:13 AM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:StrutsStarter' did not find a matching property.
Mar 15, 2012 1:34:13 AM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:StudentRecord' did not find a matching property.
Mar 15, 2012 1:34:13 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Mar 15, 2012 1:34:13 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Mar 15, 2012 1:34:13 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 634 ms
Mar 15, 2012 1:34:13 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Mar 15, 2012 1:34:13 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.25
Mar 15, 2012 1:34:15 AM org.apache.catalina.core.StandardContext resourcesStart
SEVERE: Error starting static Resources
java.lang.IllegalArgumentException: Document base C:\Users\cire\Documents\softdev-workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\StrutsStarter does not exist or is not a readable directory
at org.apache.naming.resources.FileDirContext.setDocBase(FileDirContext.java:140)
at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:4894)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5074)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1568)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1558)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Mar 15, 2012 1:34:15 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error in resourceStart()
Mar 15, 2012 1:34:15 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error getConfigured
Mar 15, 2012 1:34:15 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/StrutsStarter] startup failed due to previous errors
Mar 15, 2012 1:34:15 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Mar 15, 2012 1:34:15 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Mar 15, 2012 1:34:15 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 1567 ms
-
Re: Simple Search Engine
What is it doing that it should not be doing?
Errors?
Exceptions (full stack traces included)?
-
Re: Simple Search Engine
The error at the end may be your using the wrong level of Tomcat eg 5 not 6 or 7 or maybe the SDK is old.
It also could not find a tmp file in the servers main site.