Re: [servlet]

2023-01-20 Thread Peter Scharf
Now the next step in this tutorial passes the values of variables in the java 
web form to a jsp file instead of embedding them in println commands.  Here is 
the code that the tutorial (https://www.youtube.com/watch?v=eP9oz6ZKUXM at 
Creat JavaServer Page (JSP), about 23 minutes into it) gives:

protected void doPost(HttpServletRequest request, HttpServletResponse response)
   throws ServletException, IOException {
  processRequest(request, response);
  float miles = Float.parseFloat(request.getParameter("miles"));
  float kilometers = miles * 1.61f;
  request.setAttribute("miles", miles);
  request.setAttribute("kilometers", kilometers);
  String resultPage = "result.jsp";
  
  RequestDispatcher dispatcher = request.getRequestDispatcher(resultPage);
  dispacther.forward(request, response);
   }

I get a compile error that complains about that RequestDispatcher is an 
undefined symbol.  After much hunting on websites for answers, I revised the 
code as in the project in the git: 
https://github.com/the-sanskrit-library/public.git, namely:

   protected void doPost(HttpServletRequest request, HttpServletResponse 
response)
   throws ServletException, IOException {
  float miles = Float.parseFloat(request.getParameter("miles"));
  float kilometers = miles * 1.61f;
  request.setAttribute("miles", miles);
  request.setAttribute("kilometers", kilometers);
  String resultPage = "result.jsp";
  request.getRequestDispatcher(resultPage).forward(request, response);
   }
 
Which compiles.  However, the response I get give the string rather than their 
values:

Unit Conversion Result

$(miles) miles = $(kilometers) kilometers

Any suggestions?
Yours,
Peter

**
Peter M. Scharf, President
The Sanskrit Library
sch...@sanskritlibrary.org
https://sanskritlibrary.org
**

> On Jan 20, 2023, at 12:31 PM, Carl Mosca  wrote:
> 
> You're welcome Peter and glad to hear it.  You can remove/replace the root 
> app if/as needed.
> 
> Regards,
> Carl
> 
> On Fri, Jan 20, 2023 at 1:28 PM Peter Scharf  > wrote:
>> Dear Carl,
>>  Thanks for your help.  I installed Tomcat version 9.  Now the project 
>> runs correctly.
>>  Changing the context path to “/” however, interfered with the “It 
>> works” root app of Tomcat, so I changed it back.  I get the correct result 
>> of the conversion servlet at the path 
>> http://localhost:8080/mavenproject3/convert.
>>  Yours,
>>  Peter
>> 
>> **
>> Peter M. Scharf, President
>> The Sanskrit Library
>> sch...@sanskritlibrary.org 
>> https://sanskritlibrary.org 
>> **
>> 
>>> On Jan 18, 2023, at 8:16 PM, Carl Mosca >> > wrote:
>>> 
>>> Hi Peter,
>>> 
>>> First off it looks like the example notes suggest using Tomcat 9 or earlier 
>>> so I used 9.0.71.
>>> 
>>> I changed the context path (in the context.xml file): .
>>> 
>>> It's worth looking at creating a .gitignore file so that class and other 
>>> binaries are not in git as they are not needed.
>>> 
>>> Regards,
>>> Carl
>>> 
>>> On Wed, Jan 18, 2023 at 6:16 PM Peter Scharf >> > wrote:
 The catalina log has lots of info entries.  Here’s one WARNING:
 
 18-Jan-2023 12:10:12.964 WARNING [main] 
 org.apache.catalina.startup.HostConfig.deployDescriptor The path attribute 
 with value [/mavenproject3] in deployment descriptor 
 [/usr/local/apache-tomcat-10.0.23/conf/Catalina/localhost/mavenproject3.xml]
  has been ignored
 
 The catalina.out file has the same suspicious entry:
 
 18-Jan-2023 12:10:12.964 WARNING [main] 
 org.apache.catalina.startup.HostConfig.deployDescriptor The path attribute 
 with value [/mavenproject3] in deployment descriptor 
 [/usr/local/apache-tomcat-10.0.23/conf/Catalina/localhost/mavenproject3.xml]
  has been ignored
 
 The localhost_access_log.2023-01-18.txt file has:
 
 0:0:0:0:0:0:0:1 - - [18/Jan/2023:12:10:18 -0600] "GET /convert HTTP/1.1" 
 404 759
 0:0:0:0:0:0:0:1 - - [18/Jan/2023:12:10:18 -0600] "GET /favicon.ico 
 HTTP/1.1" 200 21630
 0:0:0:0:0:0:0:1 - - [18/Jan/2023:16:50:07 -0600] "GET /mavenproject3/ 
 HTTP/1.1" 200 453
 0:0:0:0:0:0:0:1 - - [18/Jan/2023:16:50:14 -0600] "POST 
 /mavenproject3/convert HTTP/1.1" 404 777
 0:0:0:0:0:0:0:1 - - [18/Jan/2023:16:51:11 -0600] "POST 
 /mavenproject3/convert HTTP/1.1" 404 777
 
 Regarding Java EE versus Jakarta EE, a quick search shows that none of my 
 project files contain ‘jakarta’ while the following all contain ‘java’
 
 UnitConverterServlet.class
 UnitConverterServlet.class
 UnitConverterServlet.java
 inputFiles.lst
 javaee-endorsed-api-7.0.jar
 pom.xml
 

Re: [servlet]

2023-01-20 Thread Eric Bresie
By the way, I believe these warnings are due to conflicting configuration
methods.  Can configure them in the descriptor or with  annotations which I
believe may take preference.  Maybe there were some conflicting
configurations in use and/or limiting the wrong place to correct.

Glad it works now.

Eric B

On Wed, Jan 18, 2023 at 5:16 PM Peter Scharf 
wrote:

> The catalina log has lots of info entries.  Here’s one WARNING:
>
> 18-Jan-2023 12:10:12.964 WARNING [main]
> org.apache.catalina.startup.HostConfig.deployDescriptor The path attribute
> with value [/mavenproject3] in deployment descriptor
> [/usr/local/apache-tomcat-10.0.23/conf/Catalina/localhost/mavenproject3.xml]
> has been ignored
>
> The catalina.out file has the same suspicious entry:
>
> 18-Jan-2023 12:10:12.964 WARNING [main]
> org.apache.catalina.startup.HostConfig.deployDescriptor The path attribute
> with value [/mavenproject3] in deployment descriptor
> [/usr/local/apache-tomcat-10.0.23/conf/Catalina/localhost/mavenproject3.xml]
> has been ignored
>
> The localhost_access_log.2023-01-18.txt file has:
>
> 0:0:0:0:0:0:0:1 - - [18/Jan/2023:12:10:18 -0600] "GET /convert HTTP/1.1"
> 404 759
> 0:0:0:0:0:0:0:1 - - [18/Jan/2023:12:10:18 -0600] "GET /favicon.ico
> HTTP/1.1" 200 21630
> 0:0:0:0:0:0:0:1 - - [18/Jan/2023:16:50:07 -0600] "GET /mavenproject3/
> HTTP/1.1" 200 453
> 0:0:0:0:0:0:0:1 - - [18/Jan/2023:16:50:14 -0600] "POST
> /mavenproject3/convert HTTP/1.1" 404 777
> 0:0:0:0:0:0:0:1 - - [18/Jan/2023:16:51:11 -0600] "POST
> /mavenproject3/convert HTTP/1.1" 404 777
>
> Regarding Java EE versus Jakarta EE, a quick search shows that none of my
> project files contain ‘jakarta’ while the following all contain ‘java’
>
> UnitConverterServlet.class
> UnitConverterServlet.class
> UnitConverterServlet.java
> inputFiles.lst
> javaee-endorsed-api-7.0.jar
> pom.xml
>
>
>
> **
> Peter M. Scharf, President
> The Sanskrit Library
> sch...@sanskritlibrary.org
> https://sanskritlibrary.org
> **
>
> On Jan 18, 2023, at 12:19 PM, Eric Bresie  wrote:
>
> Does anything show up in tomcat log?
>
> I seem to recall there is some migration going on to move namespace from
> Java EE to jakarta EE name space.  Not sure if maybe that is coming into
> play here.  This might help if it is impacted
>
> https://github.com/apache/tomcat-jakartaee-migration
>
>
>
> On Wed, Jan 18, 2023 at 12:11 PM Peter Scharf 
> wrote:
>
>> Thanks, Eric.  I had tried that.  I get the message:
>>
>> HTTP Status 404 – Not Found
>> --
>>
>> *Type* Status Report
>>
>> *Message* The requested resource [/convert] is not available
>>
>> *Description* The origin server did not find a current representation
>> for the target resource or is not willing to disclose that one exists.
>> --
>> Apache Tomcat/10.0.23
>>
>> **
>> Peter M. Scharf, President
>> The Sanskrit Library
>> sch...@sanskritlibrary.org
>> https://sanskritlibrary.org
>> **
>>
>> On Jan 18, 2023, at 12:06 PM, Eric Bresie  wrote:
>>
>>
>> Servlet says the urlpattern is “/convert”
>>
>> Try
>> http://localhost:8080/convert
>>
>>
>> On Wed, Jan 18, 2023 at 11:51 AM Peter Scharf 
>> wrote:
>>
>>> Yes, the URL is correct:
>>> https://github.com/the-sanskrit-library/public.git
>>> The git directory hierarchy deceived me: I had the code outside the git
>>> directory.  I have now moved it into the git directory.
>>> Forgive me; I’m not very familiar with git and am using the desktop
>>> version.
>>> Yours,
>>> Peter
>>>
>>> **
>>> Peter M. Scharf, President
>>> The Sanskrit Library
>>> sch...@sanskritlibrary.org
>>> https://sanskritlibrary.org
>>> **
>>>
>>> On Jan 18, 2023, at 5:35 AM, Carl Mosca  wrote:
>>>
>>> Hi Peter,
>>>
>>> Can you confirm that url please.  I am not seeing Java code there; only
>>> a README and attribute file.
>>>
>>> Regards,
>>> Carl
>>>
>>>
>>> On Tue, Jan 17, 2023 at 10:40 PM Peter Scharf <
>>> sch...@sanskritlibrary.org> wrote:
>>>
 Thank you for suggesting to put the project on Github.  I have now
 created a public repository at the following url:

 https://github.com/the-sanskrit-library/public.git

 The project is in the NetBeans directory.
 Yours,
 Peter

 **
 Peter M. Scharf, President
 The Sanskrit Library
 sch...@sanskritlibrary.org
 https://sanskritlibrary.org
 **

 On Jan 17, 2023, at 2:38 PM, Carl Mosca  wrote:

 Hello Peter,

 Is the project that you created somewhere (such as Github) such that
 folks could take a look at it?

 Regards,
 Carl

 On Mon, Jan 16, 2023 at 11:21 PM Peter Scharf <
 sch...@sanskritlibrary.org> wrote:

> I just installed NetBeans 16 on a MacBook Pro with an M chip:
>
> 

Re: [servlet]

2023-01-20 Thread Carl Mosca
You're welcome Peter and glad to hear it.  You can remove/replace the root
app if/as needed.

Regards,
Carl

On Fri, Jan 20, 2023 at 1:28 PM Peter Scharf 
wrote:

> Dear Carl,
> Thanks for your help.  I installed Tomcat version 9.  Now the project runs
> correctly.
> Changing the context path to “/” however, interfered with the “It works”
> root app of Tomcat, so I changed it back.  I get the correct result of the
> conversion servlet at the path http://localhost:8080/mavenproject3/convert
> .
> Yours,
> Peter
>
> **
> Peter M. Scharf, President
> The Sanskrit Library
> sch...@sanskritlibrary.org
> https://sanskritlibrary.org
> **
>
> On Jan 18, 2023, at 8:16 PM, Carl Mosca  wrote:
>
> Hi Peter,
>
> First off it looks like the example notes suggest using Tomcat 9 or
> earlier so I used 9.0.71.
>
> I changed the context path (in the context.xml file): .
>
> It's worth looking at creating a .gitignore file so that class and other
> binaries are not in git as they are not needed.
>
> Regards,
> Carl
>
> On Wed, Jan 18, 2023 at 6:16 PM Peter Scharf 
> wrote:
>
>> The catalina log has lots of info entries.  Here’s one WARNING:
>>
>> 18-Jan-2023 12:10:12.964 WARNING [main]
>> org.apache.catalina.startup.HostConfig.deployDescriptor The path attribute
>> with value [/mavenproject3] in deployment descriptor
>> [/usr/local/apache-tomcat-10.0.23/conf/Catalina/localhost/mavenproject3.xml]
>> has been ignored
>>
>> The catalina.out file has the same suspicious entry:
>>
>> 18-Jan-2023 12:10:12.964 WARNING [main]
>> org.apache.catalina.startup.HostConfig.deployDescriptor The path attribute
>> with value [/mavenproject3] in deployment descriptor
>> [/usr/local/apache-tomcat-10.0.23/conf/Catalina/localhost/mavenproject3.xml]
>> has been ignored
>>
>> The localhost_access_log.2023-01-18.txt file has:
>>
>> 0:0:0:0:0:0:0:1 - - [18/Jan/2023:12:10:18 -0600] "GET /convert HTTP/1.1"
>> 404 759
>> 0:0:0:0:0:0:0:1 - - [18/Jan/2023:12:10:18 -0600] "GET /favicon.ico
>> HTTP/1.1" 200 21630
>> 0:0:0:0:0:0:0:1 - - [18/Jan/2023:16:50:07 -0600] "GET /mavenproject3/
>> HTTP/1.1" 200 453
>> 0:0:0:0:0:0:0:1 - - [18/Jan/2023:16:50:14 -0600] "POST
>> /mavenproject3/convert HTTP/1.1" 404 777
>> 0:0:0:0:0:0:0:1 - - [18/Jan/2023:16:51:11 -0600] "POST
>> /mavenproject3/convert HTTP/1.1" 404 777
>>
>> Regarding Java EE versus Jakarta EE, a quick search shows that none of my
>> project files contain ‘jakarta’ while the following all contain ‘java’
>>
>> UnitConverterServlet.class
>> UnitConverterServlet.class
>> UnitConverterServlet.java
>> inputFiles.lst
>> javaee-endorsed-api-7.0.jar
>> pom.xml
>>
>>
>>
>> **
>> Peter M. Scharf, President
>> The Sanskrit Library
>> sch...@sanskritlibrary.org
>> https://sanskritlibrary.org
>> **
>>
>> On Jan 18, 2023, at 12:19 PM, Eric Bresie  wrote:
>>
>> Does anything show up in tomcat log?
>>
>> I seem to recall there is some migration going on to move namespace from
>> Java EE to jakarta EE name space.  Not sure if maybe that is coming into
>> play here.  This might help if it is impacted
>>
>> https://github.com/apache/tomcat-jakartaee-migration
>>
>>
>>
>> On Wed, Jan 18, 2023 at 12:11 PM Peter Scharf 
>> wrote:
>>
>>> Thanks, Eric.  I had tried that.  I get the message:
>>>
>>> HTTP Status 404 – Not Found
>>> --
>>>
>>> *Type* Status Report
>>>
>>> *Message* The requested resource [/convert] is not available
>>>
>>> *Description* The origin server did not find a current representation
>>> for the target resource or is not willing to disclose that one exists.
>>> --
>>> Apache Tomcat/10.0.23
>>>
>>> **
>>> Peter M. Scharf, President
>>> The Sanskrit Library
>>> sch...@sanskritlibrary.org
>>> https://sanskritlibrary.org
>>> **
>>>
>>> On Jan 18, 2023, at 12:06 PM, Eric Bresie  wrote:
>>>
>>>
>>> Servlet says the urlpattern is “/convert”
>>>
>>> Try
>>> http://localhost:8080/convert
>>>
>>>
>>> On Wed, Jan 18, 2023 at 11:51 AM Peter Scharf <
>>> sch...@sanskritlibrary.org> wrote:
>>>
 Yes, the URL is correct:
 https://github.com/the-sanskrit-library/public.git
 The git directory hierarchy deceived me: I had the code outside the git
 directory.  I have now moved it into the git directory.
 Forgive me; I’m not very familiar with git and am using the desktop
 version.
 Yours,
 Peter

 **
 Peter M. Scharf, President
 The Sanskrit Library
 sch...@sanskritlibrary.org
 https://sanskritlibrary.org
 **

 On Jan 18, 2023, at 5:35 AM, Carl Mosca  wrote:

 Hi Peter,

 Can you confirm that url please.  I am not seeing Java code there; only
 a README and attribute file.

 Regards,
 Carl


 On Tue, Jan 17, 2023 at 10:40 PM Peter Scharf <

Re: [servlet]

2023-01-20 Thread Peter Scharf
Dear Carl,
Thanks for your help.  I installed Tomcat version 9.  Now the project 
runs correctly.
Changing the context path to “/” however, interfered with the “It 
works” root app of Tomcat, so I changed it back.  I get the correct result of 
the conversion servlet at the path http://localhost:8080/mavenproject3/convert.
Yours,
Peter

**
Peter M. Scharf, President
The Sanskrit Library
sch...@sanskritlibrary.org
https://sanskritlibrary.org
**

> On Jan 18, 2023, at 8:16 PM, Carl Mosca  wrote:
> 
> Hi Peter,
> 
> First off it looks like the example notes suggest using Tomcat 9 or earlier 
> so I used 9.0.71.
> 
> I changed the context path (in the context.xml file): .
> 
> It's worth looking at creating a .gitignore file so that class and other 
> binaries are not in git as they are not needed.
> 
> Regards,
> Carl
> 
> On Wed, Jan 18, 2023 at 6:16 PM Peter Scharf  > wrote:
>> The catalina log has lots of info entries.  Here’s one WARNING:
>> 
>> 18-Jan-2023 12:10:12.964 WARNING [main] 
>> org.apache.catalina.startup.HostConfig.deployDescriptor The path attribute 
>> with value [/mavenproject3] in deployment descriptor 
>> [/usr/local/apache-tomcat-10.0.23/conf/Catalina/localhost/mavenproject3.xml] 
>> has been ignored
>> 
>> The catalina.out file has the same suspicious entry:
>> 
>> 18-Jan-2023 12:10:12.964 WARNING [main] 
>> org.apache.catalina.startup.HostConfig.deployDescriptor The path attribute 
>> with value [/mavenproject3] in deployment descriptor 
>> [/usr/local/apache-tomcat-10.0.23/conf/Catalina/localhost/mavenproject3.xml] 
>> has been ignored
>> 
>> The localhost_access_log.2023-01-18.txt file has:
>> 
>> 0:0:0:0:0:0:0:1 - - [18/Jan/2023:12:10:18 -0600] "GET /convert HTTP/1.1" 404 
>> 759
>> 0:0:0:0:0:0:0:1 - - [18/Jan/2023:12:10:18 -0600] "GET /favicon.ico HTTP/1.1" 
>> 200 21630
>> 0:0:0:0:0:0:0:1 - - [18/Jan/2023:16:50:07 -0600] "GET /mavenproject3/ 
>> HTTP/1.1" 200 453
>> 0:0:0:0:0:0:0:1 - - [18/Jan/2023:16:50:14 -0600] "POST 
>> /mavenproject3/convert HTTP/1.1" 404 777
>> 0:0:0:0:0:0:0:1 - - [18/Jan/2023:16:51:11 -0600] "POST 
>> /mavenproject3/convert HTTP/1.1" 404 777
>> 
>> Regarding Java EE versus Jakarta EE, a quick search shows that none of my 
>> project files contain ‘jakarta’ while the following all contain ‘java’
>> 
>> UnitConverterServlet.class
>> UnitConverterServlet.class
>> UnitConverterServlet.java
>> inputFiles.lst
>> javaee-endorsed-api-7.0.jar
>> pom.xml
>> 
>> 
>> 
>> **
>> Peter M. Scharf, President
>> The Sanskrit Library
>> sch...@sanskritlibrary.org 
>> https://sanskritlibrary.org 
>> **
>> 
>>> On Jan 18, 2023, at 12:19 PM, Eric Bresie >> > wrote:
>>> 
>>> Does anything show up in tomcat log?
>>> 
>>> I seem to recall there is some migration going on to move namespace from 
>>> Java EE to jakarta EE name space.  Not sure if maybe that is coming into 
>>> play here.  This might help if it is impacted
>>> 
>>> https://github.com/apache/tomcat-jakartaee-migration
>>> 
>>> 
>>> 
>>> On Wed, Jan 18, 2023 at 12:11 PM Peter Scharf >> > wrote:
 Thanks, Eric.  I had tried that.  I get the message:
 
 HTTP Status 404 – Not Found
 
 Type Status Report
 
 Message The requested resource [/convert] is not available
 
 Description The origin server did not find a current representation for 
 the target resource or is not willing to disclose that one exists.
 
 Apache Tomcat/10.0.23
 
 
 **
 Peter M. Scharf, President
 The Sanskrit Library
 sch...@sanskritlibrary.org 
 https://sanskritlibrary.org 
 **
 
> On Jan 18, 2023, at 12:06 PM, Eric Bresie  > wrote:
> 
> 
> Servlet says the urlpattern is “/convert”
> 
> Try 
> http://localhost:8080/convert
> 
> 
> On Wed, Jan 18, 2023 at 11:51 AM Peter Scharf  > wrote:
>> Yes, the URL is correct: 
>> https://github.com/the-sanskrit-library/public.git
>> The git directory hierarchy deceived me: I had the code outside the git 
>> directory.  I have now moved it into the git directory.
>> Forgive me; I’m not very familiar with git and am using the desktop 
>> version.
>> Yours,
>> Peter
>> 
>> **
>> Peter M. Scharf, President
>> The Sanskrit Library
>> sch...@sanskritlibrary.org 
>> https://sanskritlibrary.org 
>> **
>> 
>>> On Jan 18, 2023, at