Bird757
asked on
jsp Beginners question - how do I interpret the INCLUDE statement
I am having to check/edit some jsp code because my developer has gone awol! My background is in MS SQL with a basic understanding of ASP so please excuse the simplicity of the question.
I am running a simple WAP site.
When I start Tomcat (5.5.30) I notice a file being sought - wurfl.xml.
TOMCAT OUTPUT:
Last try. Looking for wurfl.xml in temp directory
C:\temp\wurfl.xml found! I'll use this
trying to see if we can figure out the patch file
potential patchfile: C:\temp\wurfl_patch.xml
Patching OK. Applied
WURFL has been initialized
Searching the code I find the following reference:
<%@page import="net.sourceforge.wu rfl.wurfla pi.ListMan ager"%>
Where should I put the wurfl.xml and _patch files?
I am running a simple WAP site.
When I start Tomcat (5.5.30) I notice a file being sought - wurfl.xml.
TOMCAT OUTPUT:
Last try. Looking for wurfl.xml in temp directory
C:\temp\wurfl.xml found! I'll use this
trying to see if we can figure out the patch file
potential patchfile: C:\temp\wurfl_patch.xml
Patching OK. Applied
WURFL has been initialized
Searching the code I find the following reference:
<%@page import="net.sourceforge.wu
Where should I put the wurfl.xml and _patch files?
it is a sourceforge opensource project. For detail you may visit the respective page on http://sourceforge.net
put it it web-inf floder
ASKER
I have checked the SourceForge site - not being a linux/unix developer myself I am not used to open source sites and have been unable to find anything helpful. There is a big disclaimer on the site saying a person who asks a dumb question will be banned! I know my questions at this time are really basic so am asking here instead of trying to follow threads I have no knowledge of.
OK the idea of putting the file in the web-inf folder I had already tried - no luck there.
I have placed the file in c:\temp (and that works) - but that is not a good place in my opinion.
The debug suggestion is to create a wurfl.properties file, and invlude the path in that file. I have done this (creating a text file, renaming to wurfl.properties, adding into that file the path to wurfl.xml) - still no luck.
As soon as I delete (rename) the wurfl.xml in c:\temp Tomcat throws an error (I have pasted the error below) ... and this error also suggests initialising in initFromWebApplication() - but I can't find this anywhere in the existing code.
I am sure this is all straight-forward for someone familiar with JME and jsp - this is my first poke around in the code and I have no idea where to start.
The Tomcat Error output is below - any guidance will be great:
Last try. Looking for wurfl.xml in temp directory
WURFL not found anywhere
You have 3 possibilities:
- define wurfl.properties in the same directory
as your application and provide the wurfl.xml path
ex: wurflpath = file://C:\projects\wurfl\r esources\w urfl.xml
- place wurfl.xml in either C:\temp (Windows) or /tmp (Unix)
In a servlet environment, initFromWebApplication() can be used to initialize
using the wurfl at /WEB-INF/wurfl.xml
- the API will also look at the 'wurflpath' System property
OK the idea of putting the file in the web-inf folder I had already tried - no luck there.
I have placed the file in c:\temp (and that works) - but that is not a good place in my opinion.
The debug suggestion is to create a wurfl.properties file, and invlude the path in that file. I have done this (creating a text file, renaming to wurfl.properties, adding into that file the path to wurfl.xml) - still no luck.
As soon as I delete (rename) the wurfl.xml in c:\temp Tomcat throws an error (I have pasted the error below) ... and this error also suggests initialising in initFromWebApplication() - but I can't find this anywhere in the existing code.
I am sure this is all straight-forward for someone familiar with JME and jsp - this is my first poke around in the code and I have no idea where to start.
The Tomcat Error output is below - any guidance will be great:
Last try. Looking for wurfl.xml in temp directory
WURFL not found anywhere
You have 3 possibilities:
- define wurfl.properties in the same directory
as your application and provide the wurfl.xml path
ex: wurflpath = file://C:\projects\wurfl\r
- place wurfl.xml in either C:\temp (Windows) or /tmp (Unix)
In a servlet environment, initFromWebApplication() can be used to initialize
using the wurfl at /WEB-INF/wurfl.xml
- the API will also look at the 'wurflpath' System property
>how do I interpret the INCLUDE statement
Which include statement are you referring to ?
I haven't used this API but I took a quick look. I saw
http://wurfl.sourceforge.net/faq5.php#570
Please look in your web app's WEB-INF/Classes directory.
If you find the file
Init.java
or the file
WurflServletInit.java
then post them here.
Maybe one of us will be able to help you.
Also, check and see if the files WurflServletInit.class or Init.class is located in the WEB-INF/Classes directory.
Which include statement are you referring to ?
I haven't used this API but I took a quick look. I saw
http://wurfl.sourceforge.net/faq5.php#570
Please look in your web app's WEB-INF/Classes directory.
If you find the file
Init.java
or the file
WurflServletInit.java
then post them here.
Maybe one of us will be able to help you.
Also, check and see if the files WurflServletInit.class or Init.class is located in the WEB-INF/Classes directory.
I found this page too.
http://wurfl.sourceforge.net/njava/
It says
"web.xml is the easiest way to configure the API for your needs."
Please post your web app's web.xml
http://wurfl.sourceforge.net/njava/
It says
"web.xml is the easiest way to configure the API for your needs."
Please post your web app's web.xml
ASKER
Thanks rrz - that looks like a link worth going through in detail.
I think there is something very basic I am missing here. It is not easy taking over some code without any idea of how it should be structured.
On the web.xml = I did notice earlier my developed did not have a web.xml file so I copied one from another project and have edited the very basics in it (I have no idea what I am doing here I do admit). What I have is below. I added the reference to wurfl.zip but still no luck. It keeps looking in c:\temp for it.
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>UTrackIT</di splay-name >
<welcome-file-list>
<welcome-file>index.jsp</w elcome-fil e>
</welcome-file-list>
<context-param>
<param-name>wurfl</param-n ame>
<param-value>/WEB-INF/wurf l.zip</par am-value>
</context-param>
<session-config>
<session-timeout>
15
</session-timeout>
</session-config>
</web-app>
The Tomcat startup reports the info below (if this is helpful)
23 Aug 2010 7:47:03 PM org.apache.catalina.core.A prLifecycl eListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performanc
e in production environments was not found on the java.library.path: C:\jdk1.5\b
in;.;C:\Windows\Sun\Java\b in;C:\Wind ows\system 32;C:\Wind ows;C:\Win dows\syste m32;
C:\Windows;C:\Windows\Syst em32\Wbem; C:\Windows \System32\ WindowsPow erShell\v1 .0\;
C:\Program Files (x86)\Dell\SysMgt\RAC5;C:\ Program Files (x86)\Dell\SysMgt\oma\b
in;C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;C:\ Program Files\
Microsoft SQL Server\100\Tools\Binn\;C:\ Program Files\Microsoft SQL Server\100\D
TS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSSh ell\Comm
on7\IDE\;C:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\
23 Aug 2010 7:47:03 PM org.apache.coyote.http11.H ttp11BaseP rotocol init
INFO: Initializing Coyote HTTP/1.1 on http-192.168.100.34-80
23 Aug 2010 7:47:03 PM org.apache.catalina.startu p.Catalina load
INFO: Initialization processed in 489 ms
23 Aug 2010 7:47:03 PM org.apache.catalina.core.S tandardSer vice start
INFO: Starting service Catalina
23 Aug 2010 7:47:03 PM org.apache.catalina.core.S tandardEng ine start
INFO: Starting Servlet Engine: Apache Tomcat/5.5.30
23 Aug 2010 7:47:03 PM org.apache.catalina.core.S tandardHos t start
INFO: XML validation disabled
----START init DB----
getting the connection took: 453 milli seconds
----DONE init DB----
23 Aug 2010 7:47:04 PM org.apache.coyote.http11.H ttp11BaseP rotocol start
INFO: Starting Coyote HTTP/1.1 on http-192.168.100.34-80
23 Aug 2010 7:47:04 PM org.apache.jk.common.Chann elSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
23 Aug 2010 7:47:04 PM org.apache.jk.server.JkMai n start
INFO: Jk running ID=0 time=0/15 config=null
23 Aug 2010 7:47:04 PM org.apache.catalina.storec onfig.Stor eLoader load
INFO: Find registry server-registry.xml at classpath resource
23 Aug 2010 7:47:04 PM org.apache.catalina.startu p.Catalina start
INFO: Server startup in 1470 ms
Last try. Looking for wurfl.xml in temp directory
C:\temp\wurfl.xml found! I'll use this
trying to see if we can figure out the patch file
potential patchfile: C:\temp\wurfl_patch.xml does not exist, or is not readable
WURFL has been initialized
I think there is something very basic I am missing here. It is not easy taking over some code without any idea of how it should be structured.
On the web.xml = I did notice earlier my developed did not have a web.xml file so I copied one from another project and have edited the very basics in it (I have no idea what I am doing here I do admit). What I have is below. I added the reference to wurfl.zip but still no luck. It keeps looking in c:\temp for it.
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>UTrackIT</di
<welcome-file-list>
<welcome-file>index.jsp</w
</welcome-file-list>
<context-param>
<param-name>wurfl</param-n
<param-value>/WEB-INF/wurf
</context-param>
<session-config>
<session-timeout>
15
</session-timeout>
</session-config>
</web-app>
The Tomcat startup reports the info below (if this is helpful)
23 Aug 2010 7:47:03 PM org.apache.catalina.core.A
INFO: The APR based Apache Tomcat Native library which allows optimal performanc
e in production environments was not found on the java.library.path: C:\jdk1.5\b
in;.;C:\Windows\Sun\Java\b
C:\Windows;C:\Windows\Syst
C:\Program Files (x86)\Dell\SysMgt\RAC5;C:\
in;C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;C:\
Microsoft SQL Server\100\Tools\Binn\;C:\
TS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSSh
on7\IDE\;C:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\
23 Aug 2010 7:47:03 PM org.apache.coyote.http11.H
INFO: Initializing Coyote HTTP/1.1 on http-192.168.100.34-80
23 Aug 2010 7:47:03 PM org.apache.catalina.startu
INFO: Initialization processed in 489 ms
23 Aug 2010 7:47:03 PM org.apache.catalina.core.S
INFO: Starting service Catalina
23 Aug 2010 7:47:03 PM org.apache.catalina.core.S
INFO: Starting Servlet Engine: Apache Tomcat/5.5.30
23 Aug 2010 7:47:03 PM org.apache.catalina.core.S
INFO: XML validation disabled
----START init DB----
getting the connection took: 453 milli seconds
----DONE init DB----
23 Aug 2010 7:47:04 PM org.apache.coyote.http11.H
INFO: Starting Coyote HTTP/1.1 on http-192.168.100.34-80
23 Aug 2010 7:47:04 PM org.apache.jk.common.Chann
INFO: JK: ajp13 listening on /0.0.0.0:8009
23 Aug 2010 7:47:04 PM org.apache.jk.server.JkMai
INFO: Jk running ID=0 time=0/15 config=null
23 Aug 2010 7:47:04 PM org.apache.catalina.storec
INFO: Find registry server-registry.xml at classpath resource
23 Aug 2010 7:47:04 PM org.apache.catalina.startu
INFO: Server startup in 1470 ms
Last try. Looking for wurfl.xml in temp directory
C:\temp\wurfl.xml found! I'll use this
trying to see if we can figure out the patch file
potential patchfile: C:\temp\wurfl_patch.xml does not exist, or is not readable
WURFL has been initialized
Please tell us what API you are using.
What did you download ?
Where did you get it(show link) ?
The reason I ask is because it looks like there are two different possibilities.
http://wurfl.sourceforge.net/java/api2docs/net/sourceforge/wurfl/wurflapi/package-summary.html
http://wurfl.sourceforge.net/njava/javadocs/
The second is the newer one.
If you are using the newer one, then you should try adding
<listener>
<listener-class>
net.sourceforge.wurfl.core .web.WURFL ServletCon textListen er
</listener-class>
</listener>
to what you already have in your web.xml file.
What did you download ?
Where did you get it(show link) ?
The reason I ask is because it looks like there are two different possibilities.
http://wurfl.sourceforge.net/java/api2docs/net/sourceforge/wurfl/wurflapi/package-summary.html
http://wurfl.sourceforge.net/njava/javadocs/
The second is the newer one.
If you are using the newer one, then you should try adding
<listener>
<listener-class>
net.sourceforge.wurfl.core
</listener-class>
</listener>
to what you already have in your web.xml file.
><%@page import="net.sourceforge.wu rfl.wurfla pi.ListMan ager"%>
I think that you are using the API in the first link(in my last post). Don't add the listener tag.
So, that it seem that you are using WurflServletInit. Go back to my first post and answer the questions I asked there.
I think that you are using the API in the first link(in my last post). Don't add the listener tag.
So, that it seem that you are using WurflServletInit. Go back to my first post and answer the questions I asked there.
ASKER
I have found what I need to change - apparently the path is stored in Init.class (source is Init.java) - listed below.
I have 2 problems; the first very basic. How do I compile this .java file to .class? I copy the Init.java to my jdk/bin folder, and run javac.exe Init.class but it can't fine any of the referenced classes? Please help.
Init.java source:
package com;
import net.sourceforge.wurfl.wurf lapi.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class Init extends HttpServlet {
/**
*
*/
private static final long serialVersionUID = 1L;
public void init(ServletConfig config) throws ServletException {
super.init(config);
//Initialize WURFL with '/WEB-INF/wurfl.xml'
System.out.println("About to initialize web-app");
//ObjectsManager.initFromW ebApplicat ion(config .getServle tContext() );
ObjectsManager.initFromWeb Applicatio n("C:\\Tom cat\\webap ps\\ROOT\\ WEB-INF\\t ld\\wurfl. xml","C:\\ Tomcat\\we bapps\\ROO T\\WEB-INF \\tld\\wur fl_patch.x ml");
//ObjectsManager.initFromW ebApplicat ion("C:\\T omcat\\web apps\\ROOT \\WEB-INF\ \tld\\wurf l.xml","C: \\temp\\wu rfltest\\a nothername .xml");
}
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
response.setContentType("t ext/plain" );
PrintWriter out = response.getWriter();
out.println("init servlet (Loaded on startup for WURFL initialization)");
}
/**
* We are going to perform the same operations for POST requests
* as for GET methods, so this method just sends the request to
* the doGet method.
*/
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
doGet(request, response);
}
}
Output when I try compile:
C:\jdk1.5\bin>c:\jdk1.5\bi n\javac Init.java
Init.java:3: package net.sourceforge.wurfl.wurf lapi does not exist
import net.sourceforge.wurfl.wurf lapi.*;
^
Init.java:5: package javax.servlet does not exist
import javax.servlet.*;
^
Init.java:6: package javax.servlet.http does not exist
import javax.servlet.http.*;
^
Init.java:8: cannot find symbol
symbol: class HttpServlet
public class Init extends HttpServlet {
^
Init.java:16: cannot find symbol
symbol : class ServletConfig
location: class com.Init
public void init(ServletConfig config) throws ServletException {
^
Init.java:16: cannot find symbol
symbol : class ServletException
location: class com.Init
public void init(ServletConfig config) throws ServletException {
^
Init.java:26: cannot find symbol
symbol : class HttpServletRequest
location: class com.Init
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
^
Init.java:26: cannot find symbol
symbol : class HttpServletResponse
location: class com.Init
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
^
Init.java:26: cannot find symbol
symbol : class ServletException
location: class com.Init
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
^
Init.java:38: cannot find symbol
symbol : class HttpServletRequest
location: class com.Init
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
^
Init.java:38: cannot find symbol
symbol : class HttpServletResponse
location: class com.Init
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
^
Init.java:38: cannot find symbol
symbol : class ServletException
location: class com.Init
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
^
Init.java:17: cannot find symbol
symbol : variable super
location: class com.Init
super.init(config);
^
Init.java:21: cannot find symbol
symbol : variable ObjectsManager
location: class com.Init
ObjectsManager.initFromWeb Applicatio n("C:\\Tom cat\\webap ps\\ROOT
\\WEB-INF\\tld\\wurfl.xml" ,"C:\\Tomc at\\webapp s\\ROOT\\W EB-INF\\tl d\\wurfl_p atch
.xml");
^
14 errors
C:\jdk1.5\bin>
I have 2 problems; the first very basic. How do I compile this .java file to .class? I copy the Init.java to my jdk/bin folder, and run javac.exe Init.class but it can't fine any of the referenced classes? Please help.
Init.java source:
package com;
import net.sourceforge.wurfl.wurf
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class Init extends HttpServlet {
/**
*
*/
private static final long serialVersionUID = 1L;
public void init(ServletConfig config) throws ServletException {
super.init(config);
//Initialize WURFL with '/WEB-INF/wurfl.xml'
System.out.println("About to initialize web-app");
//ObjectsManager.initFromW
ObjectsManager.initFromWeb
//ObjectsManager.initFromW
}
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
response.setContentType("t
PrintWriter out = response.getWriter();
out.println("init servlet (Loaded on startup for WURFL initialization)");
}
/**
* We are going to perform the same operations for POST requests
* as for GET methods, so this method just sends the request to
* the doGet method.
*/
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
doGet(request, response);
}
}
Output when I try compile:
C:\jdk1.5\bin>c:\jdk1.5\bi
Init.java:3: package net.sourceforge.wurfl.wurf
import net.sourceforge.wurfl.wurf
^
Init.java:5: package javax.servlet does not exist
import javax.servlet.*;
^
Init.java:6: package javax.servlet.http does not exist
import javax.servlet.http.*;
^
Init.java:8: cannot find symbol
symbol: class HttpServlet
public class Init extends HttpServlet {
^
Init.java:16: cannot find symbol
symbol : class ServletConfig
location: class com.Init
public void init(ServletConfig config) throws ServletException {
^
Init.java:16: cannot find symbol
symbol : class ServletException
location: class com.Init
public void init(ServletConfig config) throws ServletException {
^
Init.java:26: cannot find symbol
symbol : class HttpServletRequest
location: class com.Init
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
^
Init.java:26: cannot find symbol
symbol : class HttpServletResponse
location: class com.Init
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
^
Init.java:26: cannot find symbol
symbol : class ServletException
location: class com.Init
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
^
Init.java:38: cannot find symbol
symbol : class HttpServletRequest
location: class com.Init
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
^
Init.java:38: cannot find symbol
symbol : class HttpServletResponse
location: class com.Init
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
^
Init.java:38: cannot find symbol
symbol : class ServletException
location: class com.Init
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
^
Init.java:17: cannot find symbol
symbol : variable super
location: class com.Init
super.init(config);
^
Init.java:21: cannot find symbol
symbol : variable ObjectsManager
location: class com.Init
ObjectsManager.initFromWeb
\\WEB-INF\\tld\\wurfl.xml"
.xml");
^
14 errors
C:\jdk1.5\bin>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This is a note to say Thanks for the feedback. I am working through the comments.
ASKER
Thanks for the help. I ended up struggling to get the path elements correct and ended up contracting someone who knew what they were doing; and he added a library that Apache needed that was not in any of the class paths - and installed ANT; Problem solved. I appreciate the help.