How to access Tomcat session objects directly via JavaScript?

2021-05-15 Thread leo

Hi Folks

In a small scale personal project served by Tomcat I record things per 
logged-in user. The user is available as an attribute to Tomcat’s 
session objects. In the JSP pages I retrieve the session object *through 
Java* like this


<%
HttpSession session = request.getSession();
...
user = (String)session.getAttribute("user");
...
%>

Then later on these pages *in the JavaScript* part I have:


var user = "<%=user%>"
...


In the JavaScript part I then do something with the *JavaScript* 
variable `user`.


I now would like to move away from JSP to normal HTML pages (stills 
served by Tomcat with the session backend)


Question: Can I get the content of the session object in pure 
JavaScript? Can I somehow configure Tomcat to put the session info in 
some page headers or similar so that JavaScript can read it directly?


Thanks for any pointers,
Leo

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



Tomcat JSP error message: Syntax error on token ";"

2021-05-15 Thread Jim Anderson

I'm using Tomcat 8.5.63 and in the last few days I started getting an error
message in a few of my JSP files. The error message is:

START ERROR

Type Exception Report

Message Unable to compile class for JSP:

Description The server encountered an unexpected condition that prevented
it from fulfilling the request.

Exception


org.apache.jasper.JasperException: Unable to compile class for JSP:

An error occurred at line: [1] in the jsp file: [/pages/list.jsp]
Syntax error on token ";", enum expected after this token
1: <%@ page language="java" contentType="text/html" %>
2: <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core 
" %>

3: <%@ page import = "java.io.*,java.util.*" %>
4: <%@ page import="bfs.hypBeans.HypEvent" %>


_END ERROR___


As you can see, there is no semicolon in line 1 and the error message
is showing the code exactly as it is in the tomcat/webapps/... directory.



Can anyone help explain why a semi-colon error would be reported in the 
error message when

it does not exist in the source code?



Thanks in advance for any advise/guindance.


Jim A.


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



Re: Tomcat fails to start in Docker on Amazon ECS

2021-05-15 Thread Martynas Jusevičius
My bad :) CATALINA_OPTS was malformed.

On Sat, May 15, 2021 at 10:19 AM Martynas Jusevičius
 wrote:
>
> Hi,
>
> I have a Docker image that extends tomcat:9.0.39-jdk11 and at the very
> end of the entrypoint script calls 'catalina.sh run'.
>
> This has worked fine both on my local Windows and on a CentOS server.
> However when I start a container on Amazon ECS with AMI Linux, I get
> the error below when catalina.sh is called.
> This has obviously to do with the java command, but why? Has anyone
> experienced something similar?
>
> NOTE: Picked up JDK_JAVA_OPTIONS:
> --add-opens=java.base/java.lang=ALL-UNNAMED
> --add-opens=java.base/java.io=ALL-UNNAMED
> --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
> Usage: java [options]  [args...]
>(to execute a class)
>or  java [options] -jar  [args...]
>(to execute a jar file)
>or  java [options] -m [/] [args...]
>java [options] --module [/] [args...]
>(to execute the main class in a module)
>or  java [options]  [args]
>(to execute a single source-file program)
> " Arguments following the main class, source file, -jar ,"
>  -m or --module / are passed as the arguments to
>  main class.
>  where options include:
> -cp 
> -classpath 
> --class-path 
> "  A : separated list of directories, JAR archives,"
>   and ZIP archives to search for class files.
> -p 
> --module-path ...
> "  A : separated list of directories, each directory"
>   is a directory of modules.
> --upgrade-module-path ...
> "  A : separated list of directories, each directory"
>   is a directory of modules that replace upgradeable
>   modules in the runtime image
> "--add-modules [,...]"
>   root modules to resolve in addition to the initial module.
> "   can also be ALL-DEFAULT, ALL-SYSTEM,"
>   ALL-MODULE-PATH.
> --list-modules
>   list observable modules and exit
> -d 
> --describe-module 
>   describe a module and exit
> --dry-run create VM and load main class but do not execute main 
> method.
>   The --dry-run option may be useful for validating the
>   command-line options such as the module system 
> configuration.
> --validate-modules
>   validate all modules and exit
>   The --validate-modules option may be useful for finding
>   conflicts and other errors with modules on the module path.
> -D=
>   set a system property
> -verbose:[class|module|gc|jni]
>   enable verbose output
> -version  print product version to the error stream and exit
> --version print product version to the output stream and exit
> -showversion  print product version to the error stream and continue
> --show-version
>   print product version to the output stream and continue
> --show-module-resolution
>   show module resolution output during startup
> -? -h -help
>   print this help message to the error stream
> --helpprint this help message to the output stream
> -Xprint help on extra options to the error stream
> --help-extra  print help on extra options to the output stream
> -ea[:...|:]
> -enableassertions[:...|:]
>   enable assertions with specified granularity
> -da[:...|:]
> -disableassertions[:...|:]
>   disable assertions with specified granularity
> -esa | -enablesystemassertions
>   enable system assertions
> -dsa | -disablesystemassertions
>   disable system assertions
> -agentlib:[=]
> "  load native agent library , e.g. -agentlib:jdwp"
>   see also -agentlib:jdwp=help
> -agentpath:[=]
>   load native agent library by full pathname
> -javaagent:[=]
> "  load Java programming language agent, see
> java.lang.instrument"
> -splash:
>   show splash screen with specified image
>   HiDPI scaled images are automatically supported and used
> "  if available. The unscaled image filename, e.g. image.ext,"
>   should always be passed as the argument to the -splash 
> option.
>   The most appropriate scaled image provided will be picked up
>   automatically.
>   See the SplashScreen API documentation for more information
> @argument files
>   one or more argument files containing options
> -disable-@files
>   prevent further argument file expansion
> --enable-preview
>   allow classes to depend on preview features of this release
> "To specify an 

Re: Tomcat 10 and import org.apache.commons.fileupload.FileItem problem

2021-05-15 Thread Mark Thomas

On 14/05/2021 23:17, Orendt, John wrote:

Hi

I found sample code for an UploadServlet with these imports

import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;

This worked well with Tomcat 9.

However, when I switched to a new Windows 10 device, I installed Tomcat 10.05

After, replacing javax with jakara in imports most Servlets worked well, with 
the exception of UploadServlet Which uses the above imports.


Assuming you changed your source code to use the jakarta.* imports and 
compiled your project against the Jakarta APIs (servlet-api.jar etc 
provided by Tomcat 10) then the problem is that Commons FileUpload is 
written for Java EE 8 (with javax.* packages) but you are using Jakarta 
EE 9 (with jakarta.* packages).


Commons FileUpload is working on a Jakarta EE version. In the meantime, 
you can use the Tomcat Migration Tool for Jakarta EE to convert Commons 
FileUpload to Jakarta EE and then compile against the converted JAR.


Mark

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



Tomcat fails to start in Docker on Amazon ECS

2021-05-15 Thread Martynas Jusevičius
Hi,

I have a Docker image that extends tomcat:9.0.39-jdk11 and at the very
end of the entrypoint script calls 'catalina.sh run'.

This has worked fine both on my local Windows and on a CentOS server.
However when I start a container on Amazon ECS with AMI Linux, I get
the error below when catalina.sh is called.
This has obviously to do with the java command, but why? Has anyone
experienced something similar?

NOTE: Picked up JDK_JAVA_OPTIONS:
--add-opens=java.base/java.lang=ALL-UNNAMED
--add-opens=java.base/java.io=ALL-UNNAMED
--add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
Usage: java [options]  [args...]
   (to execute a class)
   or  java [options] -jar  [args...]
   (to execute a jar file)
   or  java [options] -m [/] [args...]
   java [options] --module [/] [args...]
   (to execute the main class in a module)
   or  java [options]  [args]
   (to execute a single source-file program)
" Arguments following the main class, source file, -jar ,"
 -m or --module / are passed as the arguments to
 main class.
 where options include:
-cp 
-classpath 
--class-path 
"  A : separated list of directories, JAR archives,"
  and ZIP archives to search for class files.
-p 
--module-path ...
"  A : separated list of directories, each directory"
  is a directory of modules.
--upgrade-module-path ...
"  A : separated list of directories, each directory"
  is a directory of modules that replace upgradeable
  modules in the runtime image
"--add-modules [,...]"
  root modules to resolve in addition to the initial module.
"   can also be ALL-DEFAULT, ALL-SYSTEM,"
  ALL-MODULE-PATH.
--list-modules
  list observable modules and exit
-d 
--describe-module 
  describe a module and exit
--dry-run create VM and load main class but do not execute main method.
  The --dry-run option may be useful for validating the
  command-line options such as the module system configuration.
--validate-modules
  validate all modules and exit
  The --validate-modules option may be useful for finding
  conflicts and other errors with modules on the module path.
-D=
  set a system property
-verbose:[class|module|gc|jni]
  enable verbose output
-version  print product version to the error stream and exit
--version print product version to the output stream and exit
-showversion  print product version to the error stream and continue
--show-version
  print product version to the output stream and continue
--show-module-resolution
  show module resolution output during startup
-? -h -help
  print this help message to the error stream
--helpprint this help message to the output stream
-Xprint help on extra options to the error stream
--help-extra  print help on extra options to the output stream
-ea[:...|:]
-enableassertions[:...|:]
  enable assertions with specified granularity
-da[:...|:]
-disableassertions[:...|:]
  disable assertions with specified granularity
-esa | -enablesystemassertions
  enable system assertions
-dsa | -disablesystemassertions
  disable system assertions
-agentlib:[=]
"  load native agent library , e.g. -agentlib:jdwp"
  see also -agentlib:jdwp=help
-agentpath:[=]
  load native agent library by full pathname
-javaagent:[=]
"  load Java programming language agent, see
java.lang.instrument"
-splash:
  show splash screen with specified image
  HiDPI scaled images are automatically supported and used
"  if available. The unscaled image filename, e.g. image.ext,"
  should always be passed as the argument to the -splash option.
  The most appropriate scaled image provided will be picked up
  automatically.
  See the SplashScreen API documentation for more information
@argument files
  one or more argument files containing options
-disable-@files
  prevent further argument file expansion
--enable-preview
  allow classes to depend on preview features of this release
"To specify an argument for a long option, you can use --= or"
-- .

Martynas
atomgraph.com

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