You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by János Löbb <ja...@yale.edu> on 2011/04/27 22:26:48 UTC

Re: SessionExample from the examples webapp

Hi,

Adding some -claspath based upon man javac, I reduced the number of errors to two.

bml0065:classes administrator$ sudo javac -classpath /usr/local/apache-tomcat-7.0.10/webapps/examples/WEB-INF/classes/util:/usr/local/apache-tomcat-7.0.10/lib/servlet-api.jar SessionExample.java SessionExample.java:33: package util does not exist
import util.HTMLFilter;
           ^
SessionExample.java:100: cannot access HTMLFilter
bad class file: /usr/local/apache-tomcat-7.0.10/webapps/examples/WEB-INF/classes/util/HTMLFilter.java
file does not contain class HTMLFilter
Please remove or make sure it appears in the correct subdirectory of the classpath.
            out.println(HTMLFilter.filter(name) + " = " 
                        ^
2 errors

How can I get rid off these two ?  I tried this command too:
sudo javac -classpath /usr/local/apache-tomcat-7.0.10/webapps/examples/WEB-INF/classes/util/HTMLFilter.class:/usr/local/apache-tomcat-7.0.10/lib/servlet-api.jar SessionExample.java

and also with HTMLFilter.java in place of HTMLFilter.class, but then the number of errors climbed back to three :-(

Thanks ahead,

János



On Apr 27, 2011, at 11:25 AM, János Löbb wrote:

> Hi,
> 
> During a good night sleep I realized that I have to compile the modified .java file :-)
> 
> This is my current directory:
> 
> bml0065:classes administrator$ pwd
> /usr/local/tomcat/webapps/examples/WEB-INF/classes
> 
> 
> When I do it I am getting the following errors:
> 
> <nyissz>
> 
> bml0065:classes administrator$ sudo javac SessionExample.java 
> Password:
> SessionExample.java:27: package javax.servlet does not exist
> import javax.servlet.ServletException;
>                   ^
> SessionExample.java:28: package javax.servlet.http does not exist
> import javax.servlet.http.HttpServlet;
>                        ^
> SessionExample.java:29: package javax.servlet.http does not exist
> import javax.servlet.http.HttpServletRequest;
>                        ^
> SessionExample.java:30: package javax.servlet.http does not exist
> import javax.servlet.http.HttpServletResponse;
>                        ^
> SessionExample.java:31: package javax.servlet.http does not exist
> import javax.servlet.http.HttpSession;
>                        ^
> SessionExample.java:41: cannot find symbol
> symbol: class HttpServlet
> public class SessionExample extends HttpServlet {
>                                   ^
> SessionExample.java:48: cannot find symbol
> symbol  : class HttpServletRequest
> location: class SessionExample
>   public void doGet(HttpServletRequest request,
>                     ^
> SessionExample.java:49: cannot find symbol
> symbol  : class HttpServletResponse
> location: class SessionExample
>                     HttpServletResponse response)
>                     ^
> SessionExample.java:50: cannot find symbol
> symbol  : class ServletException
> location: class SessionExample
>       throws IOException, ServletException
>                           ^
> SessionExample.java:144: cannot find symbol
> symbol  : class HttpServletRequest
> location: class SessionExample
>   public void doPost(HttpServletRequest request,
>                      ^
> SessionExample.java:145: cannot find symbol
> symbol  : class HttpServletResponse
> location: class SessionExample
>                     HttpServletResponse response)
>                     ^
> SessionExample.java:146: cannot find symbol
> symbol  : class ServletException
> location: class SessionExample
>       throws IOException, ServletException
>                           ^
> SessionExample.java:80: cannot find symbol
> symbol  : class HttpSession
> location: class SessionExample
>       HttpSession session = request.getSession(true);
>       ^
> SessionExample.java:47: method does not override or implement a method from a supertype
>   @Override
>   ^
> SessionExample.java:143: method does not override or implement a method from a supertype
>   @Override
>   ^
> 15 errors
> 
> <nyassz>
> 
> What am I doing wrong ?  
> 
> My guess is that I need a -classpath option, so  javac can find all those definitions it needs.  What should that be on OSX 10.6.6 ?
> 
> Thanks ahead,
> 
> János
> 
> On Apr 26, 2011, at 5:25 PM, János Löbb wrote:
> 
>> Folks,
>> 
>> What should I change if I want to have as title in this servlet not "Session Example" but rather "Session Example Old"  ?
>> 
>> I modified the servlets/sessions.html and also the SessionExample.java in the WEB-INF/classes, created a war file with jar, un-deployed and re-deployed, but I do not see the change.
>> 
>> Thanks ahead,
>> 
>> János
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: SessionExample from the examples webapp

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

János,

On 4/28/2011 11:41 AM, János Löbb wrote:
> Thanks a lot for the suggestion.  Where should I look for those
> scripts ?

If you have the source, you have the build scripts: build.xml and
friends are used with Apache ant.

> In the meantime I solved - hopefully - my problem.  For some reason
> the javac did not recognized the util folder or the util package
> declaration in HTMLFilter.java in the util folder.  So I moved it out
> from the util folder one level up and commented out the package
> declaration. 

Given your description of everything, it's evident that you aren't very
familiar with building Java apps from the command-line. Are you sure you
want to be tinkering-around with the code that comes with Tomcat?

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk27PXoACgkQ9CaO5/Lv0PCYAwCgrxS88hnHAoIRFQCYJVLFBVv0
dUYAoIATA+Rn3lOMu7fQNzqcXizOBbKs
=j8ZG
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: SessionExample from the examples webapp

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: János Löbb [mailto:janos.lobb@yale.edu] 
> Subject: Re: SessionExample from the examples webapp

> Where should I look for those scripts ?

The link is on the Tomcat 7 doc page:
http://tomcat.apache.org/tomcat-7.0-doc/building.html

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: SessionExample from the examples webapp

Posted by János Löbb <ja...@yale.edu>.
Hi Chris,

Thanks a lot for the suggestion.  Where should I look for those scripts ?

In the meantime I solved - hopefully - my problem.  For some reason the javac did not recognized the util folder or the util package declaration in HTMLFilter.java in the util folder.  So I moved it out from the util folder one level up and commented out the package declaration.  The this line of javac worked:

bml0065:tomcat administrator$ sudo javac -classpath lib/servlet-api.jar:webapps/examples/WEB-INF/classes -verbose webapps/examples/WEB-INF/classes/SessionExample.java 
[parsing started webapps/examples/WEB-INF/classes/SessionExample.java]
[parsing completed 18ms]
[search path for source files: lib/servlet-api.jar,webapps/examples/WEB-INF/classes]
[search path for class files: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/jsfd.jar,/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/classes.jar,/System/Library/Frameworks/JavaVM.framework/Frameworks/JavaRuntimeSupport.framework/Resources/Java/JavaRuntimeSupport.jar,/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/ui.jar,/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/laf.jar,/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/sunrsasign.jar,/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/jsse.jar,/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/jce.jar,/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/charsets.jar,/System/Library/Java/Extensions/AppleScriptEngine.jar,/System/Library/Java/Extensions/dns_sd.jar,/System/Library/Java/Extensions/j3daudio.jar,/System/Library/Java/Extensions/j3dcore.jar,/System/Library/Java/Extensions/j3dutils.jar,/System/Library/Java/Extensions/jai_codec.jar,/System/Library/Java/Extensions/jai_core.jar,/System/Library/Java/Extensions/mlibwrapper_jai.jar,/System/Library/Java/Extensions/MRJToolkit.jar,/System/Library/Java/Extensions/QTJava.zip,/System/Library/Java/Extensions/vecmath.jar,/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/ext/apple_provider.jar,/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/ext/dnsns.jar,/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/ext/localedata.jar,/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/ext/sunjce_provider.jar,/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/ext/sunpkcs11.jar,lib/servlet-api.jar,webapps/examples/WEB-INF/classes]
[loading java/io/IOException.class(java/io:IOException.class)]
[loading java/io/PrintWriter.class(java/io:PrintWriter.class)]
[loading java/util/Date.class(java/util:Date.class)]
[loading java/util/Enumeration.class(java/util:Enumeration.class)]
[loading java/util/ResourceBundle.class(java/util:ResourceBundle.class)]
[loading javax/servlet/ServletException.class(javax/servlet:ServletException.class)]
[loading javax/servlet/http/HttpServlet.class(javax/servlet/http:HttpServlet.class)]
[loading javax/servlet/http/HttpServletRequest.class(javax/servlet/http:HttpServletRequest.class)]
[loading javax/servlet/http/HttpServletResponse.class(javax/servlet/http:HttpServletResponse.class)]
[loading javax/servlet/http/HttpSession.class(javax/servlet/http:HttpSession.class)]
[loading javax/servlet/GenericServlet.class(javax/servlet:GenericServlet.class)]
[loading javax/servlet/Servlet.class(javax/servlet:Servlet.class)]
[loading java/lang/Object.class(java/lang:Object.class)]
[loading javax/servlet/ServletConfig.class(javax/servlet:ServletConfig.class)]
[loading java/io/Serializable.class(java/io:Serializable.class)]
[loading java/lang/Override.class(java/lang:Override.class)]
[loading java/lang/annotation/Annotation.class(java/lang/annotation:Annotation.class)]
[loading java/lang/annotation/Target.class(java/lang/annotation:Target.class)]
[loading java/lang/annotation/ElementType.class(java/lang/annotation:ElementType.class)]
[loading java/lang/annotation/Retention.class(java/lang/annotation:Retention.class)]
[loading java/lang/annotation/RetentionPolicy.class(java/lang/annotation:RetentionPolicy.class)]
[checking SessionExample]
[loading java/lang/Error.class(java/lang:Error.class)]
[loading java/lang/Exception.class(java/lang:Exception.class)]
[loading java/lang/Throwable.class(java/lang:Throwable.class)]
[loading java/lang/RuntimeException.class(java/lang:RuntimeException.class)]
[loading java/lang/String.class(java/lang:String.class)]
[loading javax/servlet/ServletResponse.class(javax/servlet:ServletResponse.class)]
[loading java/io/Writer.class(java/io:Writer.class)]
[loading javax/servlet/ServletRequest.class(javax/servlet:ServletRequest.class)]
[loading webapps/examples/WEB-INF/classes/HTMLFilter.java]
[parsing started webapps/examples/WEB-INF/classes/HTMLFilter.java]
[parsing completed 4ms]
[loading java/lang/StringBuilder.class(java/lang:StringBuilder.class)]
[loading java/lang/AbstractStringBuilder.class(java/lang:AbstractStringBuilder.class)]
[loading java/lang/CharSequence.class(java/lang:CharSequence.class)]
[loading java/lang/Comparable.class(java/lang:Comparable.class)]
[loading java/lang/StringBuffer.class(java/lang:StringBuffer.class)]
[wrote webapps/examples/WEB-INF/classes/SessionExample.class]
[checking HTMLFilter]
[wrote webapps/examples/WEB-INF/classes/HTMLFilter.class]
[total 849ms]

bml0065:tomcat administrator$ pwd
/usr/local/tomcat


I still would like to know why it fails when the HTMLFilter.java and HTMLFilter.class is in the util folder.  It beats me, but if someone know why, I will drink a good glass of vine for his/her health in the weekend :-)
I just jar-ed a war from it and will deploy it soon to see if it work for me.

Thanks as always,

Jábnos
On Apr 28, 2011, at 11:24 AM, Christopher Schultz wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> János,
> 
> On 4/27/2011 4:26 PM, János Löbb wrote:
>> Adding some -claspath based upon man javac, I reduced the number of errors to two.
> 
> Save yourself some time and use the build scripts that come with Tomcat:
> they are capable of building TC with no errors because they include all
> the dependencies, etc. in whatever classpath is necessary at the time.
> 
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
> 
> iEYEARECAAYFAk25hsIACgkQ9CaO5/Lv0PA7kQCgws+TcyXomdCY9LvXkhhxxL2i
> RRwAnRM2L2FGGLGvJF0/Ep21ZJzb2vO7
> =947o
> -----END PGP SIGNATURE-----
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: SessionExample from the examples webapp

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

János,

On 4/27/2011 4:26 PM, János Löbb wrote:
> Adding some -claspath based upon man javac, I reduced the number of errors to two.

Save yourself some time and use the build scripts that come with Tomcat:
they are capable of building TC with no errors because they include all
the dependencies, etc. in whatever classpath is necessary at the time.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk25hsIACgkQ9CaO5/Lv0PA7kQCgws+TcyXomdCY9LvXkhhxxL2i
RRwAnRM2L2FGGLGvJF0/Ep21ZJzb2vO7
=947o
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: SessionExample from the examples webapp

Posted by János Löbb <ja...@yale.edu>.
On Apr 28, 2011, at 4:53 PM, Konstantin Kolinko wrote:

> 2011/4/29 János Löbb <ja...@yale.edu>:
>> Hi Konstantin, Chuck,
>> 
>> I think I tried also with .../WEB-INF/classes and it still complained that it could not find or open the util package.  Then I moved the two HTMLFilter.* files out from there a level up, commented out the package declaration in HTMLFilter.java and then javac compiled SessionExample.java and I am happy with it.  Now I know how to mess with java files from the command line with tools like nano, pico and javac :-)
>> 
>> And yes, I did not want to compile the whole Tomcat, just modify one of the servlet examples to suit my need.
>> 
>> Thanks you both,
>> 
> 
> :)  BTW, why you are using  "sudo" to invoke the compiler?  Usually
> root rights are not needed to compile a program.
> 
> And may be these pages from the official Java Tutorial may be useful to you:
> http://download.oracle.com/javase/tutorial/getStarted/cupojava/index.html
> 
> Help for javac etc. is here:
> http://download.oracle.com/javase/6/docs/technotes/tools/index.html#basic
> 
> Best regards,
> Konstantin Kolinko

Because the powers above me wanted to install and run it as root.  I know, I know...  and I recommended to set up a tomcat user who owns it... but I did not succeed.  

Thanks for the pointers,

János
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: SessionExample from the examples webapp

Posted by Konstantin Kolinko <kn...@gmail.com>.
2011/4/29 János Löbb <ja...@yale.edu>:
> Hi Konstantin, Chuck,
>
> I think I tried also with .../WEB-INF/classes and it still complained that it could not find or open the util package.  Then I moved the two HTMLFilter.* files out from there a level up, commented out the package declaration in HTMLFilter.java and then javac compiled SessionExample.java and I am happy with it.  Now I know how to mess with java files from the command line with tools like nano, pico and javac :-)
>
> And yes, I did not want to compile the whole Tomcat, just modify one of the servlet examples to suit my need.
>
> Thanks you both,
>

:)  BTW, why you are using  "sudo" to invoke the compiler?  Usually
root rights are not needed to compile a program.

And may be these pages from the official Java Tutorial may be useful to you:
http://download.oracle.com/javase/tutorial/getStarted/cupojava/index.html

Help for javac etc. is here:
http://download.oracle.com/javase/6/docs/technotes/tools/index.html#basic

Best regards,
Konstantin Kolinko

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: SessionExample from the examples webapp

Posted by János Löbb <ja...@yale.edu>.
Hi Konstantin, Chuck,

I think I tried also with .../WEB-INF/classes and it still complained that it could not find or open the util package.  Then I moved the two HTMLFilter.* files out from there a level up, commented out the package declaration in HTMLFilter.java and then javac compiled SessionExample.java and I am happy with it.  Now I know how to mess with java files from the command line with tools like nano, pico and javac :-)

And yes, I did not want to compile the whole Tomcat, just modify one of the servlet examples to suit my need.

Thanks you both,

János
On Apr 28, 2011, at 4:17 PM, Konstantin Kolinko wrote:

> 2011/4/28 János Löbb <ja...@yale.edu>:
>> Hi,
>> 
>> Adding some -claspath based upon man javac, I reduced the number of errors to two.
>> 
>> bml0065:classes administrator$ sudo javac -classpath /usr/local/apache-tomcat-7.0.10/webapps/examples/WEB-INF/classes/util:
> 
> The above should have been .../WEB-INF/classes  and not  ../WEB-INF/classes/util
> 
> /usr/local/apache-tomcat-7.0.10/lib/servlet-api.jar
> SessionExample.java SessionExample.java:33: package util does not
> exist
>> import util.HTMLFilter;
>>           ^
> 
> 
> 2 Chuck: OP is building its own app, not Tomcat.
> 
> Best regards,
> Konstantin Kolinko
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: SessionExample from the examples webapp

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Konstantin Kolinko [mailto:knst.kolinko@gmail.com] 
> Subject: Re: SessionExample from the examples webapp

> 2 Chuck: OP is building its own app, not Tomcat.

Hmmm... from the discussion, I thought the OP was building a modified examples webapp that was included with Tomcat, and therefore could use the existing Tomcat scripts - as Chris suggested.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: SessionExample from the examples webapp

Posted by Konstantin Kolinko <kn...@gmail.com>.
2011/4/28 János Löbb <ja...@yale.edu>:
> Hi,
>
> Adding some -claspath based upon man javac, I reduced the number of errors to two.
>
> bml0065:classes administrator$ sudo javac -classpath /usr/local/apache-tomcat-7.0.10/webapps/examples/WEB-INF/classes/util:

The above should have been .../WEB-INF/classes  and not  ../WEB-INF/classes/util

/usr/local/apache-tomcat-7.0.10/lib/servlet-api.jar
SessionExample.java SessionExample.java:33: package util does not
exist
> import util.HTMLFilter;
>           ^


2 Chuck: OP is building its own app, not Tomcat.

Best regards,
Konstantin Kolinko

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org