On 27.10.2022 13:13, Simon Besenbäck wrote:
I am using Apache Tomcat 10.0.23 and nashorn 15.4 in an eclipse ide in order to 
develop JSP's.
I want to send data (user input in a form) via the POST method to another JSP.
However I do not know how I can get the sent data. In Java I guess I would be using request.getParameter().
Is there a similar way to get the input using Nashorn?
I tried to play around with fetch() but I didn`t came to a solution.

You should be able to directly access the JSP implicit objects, e.g. cf. <https://www.w3schools.in/jsp/implicit-objects>, if using the ScriptTagLibs library [1], and all of their methods.

Therefore you should be able to do something like this:

   <%@ taglib uri="http://rexxla.org/taglibs/jsr223";  prefix="s" %>
   <!DOCTYPE html>
   <html>
   <head>
   <style>
        body { background-color: ivory; }
   </style>
   <title>40_helloworld_use_request.jsp: Sample Application JSP Page Using JavaScript 
Via JSR-223 (Title)</title>
   </head>

   <body>
   <s:script type="javascript">
   out.println("<h1>Hello, world (JSP with Nashorn/JavaScript)</h1>");      // 
implicit JSP object 'out'

   print("<p>This JSP was executed, because of the following URL:"  ,
          "<ul><li>URL <em>request.getRequestURL()</em>: <br><code>" ,       // 
implicit JSP object 'request'
          request.getRequestURL(), "</code>");

   print("<li>its URI being <em>request.getRequestURI()</em>: <br><code>" , // 
implicit JSP object 'request'
          request.getRequestURI(), "</code></ul></p>");
   </s:script>
   </body>
   </html>

HTH

---rony

[1]: <https://sourceforge.net/projects/bsf4oorexx/files/Sandbox/rgf/taglibs/ga/>

Reply via email to