The Struts dispatcher cannot be found.

2018-10-09 Thread s-sbergg

Hello,
Struts version 2.5.17

I am trying to setup struts 2 on tomcat, but there is coming up an 
error. The .jsp was opened directly. If there are more files needed to 
figure out what is wrong, feel free to ask.


Error-message:

HTTP Status 500 – Internal Server Error

Type Exception Report

Message An exception occurred processing JSP page /web/welcome.jsp at 
line 15


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


Exception

org.apache.jasper.JasperException: An exception occurred processing JSP 
page /web/welcome.jsp at line 15


12: Welcome
13: 
14: 
15: Hello User: 
16: 
17: 


Stacktrace:

org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:594)

org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:491)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

Root Cause

The Struts dispatcher cannot be found.  This is usually caused by using 
Struts tags without the associated filter. Struts tags are only usable 
when the request has passed through its servlet filter, which 
initializes the Struts dispatcher needed for this tag. - [unknown 
location]

org.apache.struts2.views.jsp.TagUtils.getStack(TagUtils.java:53)

org.apache.struts2.views.jsp.StrutsBodyTagSupport.getStack(StrutsBodyTagSupport.java:40)

org.apache.struts2.views.jsp.ComponentTagSupport.doStartTag(ComponentTagSupport.java:45)

org.apache.jsp.web.welcome_jsp._jspx_meth_s_005fproperty_005f0(welcome_jsp.java:131)
org.apache.jsp.web.welcome_jsp._jspService(welcome_jsp.java:95)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:731)

org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:453)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)


web.xml:


http://xmlns.jcp.org/xml/ns/javaee;
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance;
 xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee 
http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd;

 version="4.0">

Archetype Created Web Application

struts2

org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter



struts2
/*



struts-tags.tld

/WEB-INF/lib/struts2-core.jar




index.jsp




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



Re: Hidden Field Name for Token For Struts 1.3

2018-10-09 Thread Yasser Zamani



On 2018/09/25 15:41:47, hanzhid...@gmail.com  wrote: 
> Hi,
> Struts version: 1.3
> 
> Currently our web application is using  struts tag  on the jsp 
> page. This tag will generate the html response with the hidden form field 
> org.apache.struts.taglib.html.TOKEN.  This field is used for storing CSRF 
> token. We are concerned that public user accessing our web application will 
> see this field name at the browser side, and able to know that our backend 
> application is using struts. This could lead to security risk.
> 
> We would like to know if struts 1.3 allows developer to change the name of 
> the generated hidden field for storing token, so that we can change the use 
> name to other than org.apache.struts.taglib.html.TOKEN.  
> 

I don't think so as even Struts 2 doesn't have such feature. Struts 1 isn't 
supported due to EOL but thanks a lot for your tip which can being applied on 
Struts 2.

Regards.

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



RE: Struts2 - multipart/related - HttpServletRequest#getParts not working

2018-10-09 Thread Yasser Zamani
I see Struts REST plugin has a handler for multipart request but it and even 
the whole Struts framework also talks only about multipart/form-data ;) 
Unfortunately it seems Struts doesn't know such content type at all. Anyway, 
some tips can be found in net via googling "UT010016: Not a multi part request".

Regards.

>-Original Message-
>From: Nikhil P Kookkiri 
>Sent: Tuesday, October 9, 2018 10:05 AM
>To: Struts Users Mailing List ; Yasser Zamani
>
>Subject: Re: Struts2 - multipart/related - HttpServletRequest#getParts not
>working
>
>
>Hi Yesser, thanks for your response. Yes, it is the issue with the servlet. I 
>am
>suspecting that MutiPartConfig works only for multipart/form-data and does not
>work with multipart/related. I passed the request directly to HttpServlet 
>instead
>of Sturts mapped Action with @MultiPartConfig configured and I got the
>exception:
>javax.servlet.ServletException: UT010016: Not a multi part request.
>Almost all documentation I saw talks only about multipart/form-data.
>
>I am assuming using Struts rest plugin also will not help in this case.
>Kindly let me know.
>
>Best regards,
>Nikhil P kookkiri
>
>On Tuesday 09 October 2018 11:02 AM, Yasser Zamani wrote:
>> This isn't Struts issue but your underlying servlet message. Anyway, what 
>> about
>trying Struts itself file upload feature. Then ask that another app to http 
>post the
>file to a file upload action.
>>
>> Regards.
>>
>>> -Original Message-
>>> From: Nikhil P Kookkiri 
>>> Sent: Monday, October 8, 2018 12:37 PM
>>> To: user@struts.apache.org
>>> Subject: Struts2 - multipart/related - HttpServletRequest#getParts
>>> not working
>>>
>>> I have request coming from another application which is
>>> 'multipart/related'. In the mutlipart request body, I am receiving
>>> image/jpeg and application/xml. I suppose, I should be iterating over
>>> the http part obtained from getPaths method in the HttpServletRequest
>>> object and read the stream available on each of the parts. When I try doing
>that, I am getting the following error:
>>>
>>> java.lang.IllegalStateException: UT010057: multipart config was not
>>> present on Servlet ERROR [stderr] (default task-2)     at
>>> io.undertow.servlet//io.undertow.servlet.spec.HttpServletRequestImpl.
>>> verifyMul
>>> tipartServlet(HttpServletRequestImpl.java:523)
>>> ERROR [stderr] (default task-2)     at
>>> io.undertow.servlet//io.undertow.servlet.spec.HttpServletRequestImpl.
>>> getParts(
>>> HttpServletRequestImpl.java:512)
>>> ERROR [stderr] (default task-2)     at
>>> javax.servlet.api//javax.servlet.http.HttpServletRequestWrapper.getPa
>>> rts(HttpSer
>>> vletRequestWrapper.java:375)
>>>
>>> Please let me know the best possible solution for this.
>>>
>>> Here is what I am doing in the code:
>>>
>>>      public class TestMultiPart extends ActionSupport implements
>>> ServletRequestAware
>>>      {
>>>          private InputStream inputStream;
>>>          private HttpServletRequest request;
>>>
>>>      public String execute()
>>>      {
>>>          BufferedInputStream bis = null;
>>>          BufferedOutputStream bos = null;
>>>          try
>>>          {
>>>              Collection parts = request.getParts();
>>>              for(Part part : parts)
>>>              {
>>>                  String contentType = part.getContentType();
>>>                  System.out.println("Content type is: " +
>>> contentType);
>>>                  File file =
>>> getFileToDownload(getContentType(contentType));
>>>                  if(file != null)
>>>                  {
>>>                      bis = new
>>> BufferedInputStream(request.getInputStream());
>>>                      bos = new BufferedOutputStream(new
>>> FileOutputStream(file));
>>>                      byte[] bytes = new byte[bis.available()];
>>>                      while(bis.read(bytes) > 0)
>>>                      {
>>>                          bos.write(bytes);
>>>                          bos.flush();
>>>                          bytes = new byte[bis.available()];
>>>                      }
>>>                  }
>>>              }
>>>          } catch (IOException e) {
>>>              // TODO Auto-generated catch block
>>>              e.printStackTrace();
>>>          } catch (ServletException e) {
>>>              // TODO Auto-generated catch block
>>>              e.printStackTrace();
>>>          } finally {
>>>              if(bis != null)
>>>              {
>>>                  try {
>>>                      bis.close();
>>>                  } catch (IOException e) {
>>>                      // TODO Auto-generated catch block
>>>                      e.printStackTrace();
>>>                  }
>>>              }
>>>              if(bos != null)
>>>              {
>>>                  try {
>>>                      bos.close();
>>>                  } catch (IOException e) {
>>>                      // TODO Auto-generated catch block
>>>                      e.printStackTrace();
>>>               

Re: Struts2 - multipart/related - HttpServletRequest#getParts not working

2018-10-09 Thread Nikhil P Kookkiri


Hi Yesser, thanks for your response. Yes, it is the issue with the 
servlet. I am suspecting that MutiPartConfig works only for 
multipart/form-data and does not work with multipart/related. I passed 
the request directly to HttpServlet instead of Sturts mapped Action with 
@MultiPartConfig configured and I got the exception: 
javax.servlet.ServletException: UT010016: Not a multi part request. 
Almost all documentation I saw talks only about multipart/form-data.


I am assuming using Struts rest plugin also will not help in this case. 
Kindly let me know.


Best regards,
Nikhil P kookkiri

On Tuesday 09 October 2018 11:02 AM, Yasser Zamani wrote:

This isn't Struts issue but your underlying servlet message. Anyway, what about 
trying Struts itself file upload feature. Then ask that another app to http 
post the file to a file upload action.

Regards.


-Original Message-
From: Nikhil P Kookkiri 
Sent: Monday, October 8, 2018 12:37 PM
To: user@struts.apache.org
Subject: Struts2 - multipart/related - HttpServletRequest#getParts not working

I have request coming from another application which is 'multipart/related'. In
the mutlipart request body, I am receiving image/jpeg and application/xml. I
suppose, I should be iterating over the http part obtained from getPaths method
in the HttpServletRequest object and read the stream available on each of the
parts. When I try doing that, I am getting the following error:

java.lang.IllegalStateException: UT010057: multipart config was not present on
Servlet ERROR [stderr] (default task-2)     at
io.undertow.servlet//io.undertow.servlet.spec.HttpServletRequestImpl.verifyMul
tipartServlet(HttpServletRequestImpl.java:523)
ERROR [stderr] (default task-2)     at
io.undertow.servlet//io.undertow.servlet.spec.HttpServletRequestImpl.getParts(
HttpServletRequestImpl.java:512)
ERROR [stderr] (default task-2)     at
javax.servlet.api//javax.servlet.http.HttpServletRequestWrapper.getParts(HttpSer
vletRequestWrapper.java:375)

Please let me know the best possible solution for this.

Here is what I am doing in the code:

     public class TestMultiPart extends ActionSupport implements
ServletRequestAware
     {
         private InputStream inputStream;
         private HttpServletRequest request;

     public String execute()
     {
         BufferedInputStream bis = null;
         BufferedOutputStream bos = null;
         try
         {
             Collection parts = request.getParts();
             for(Part part : parts)
             {
                 String contentType = part.getContentType();
                 System.out.println("Content type is: " + contentType);
                 File file = getFileToDownload(getContentType(contentType));
                 if(file != null)
                 {
                     bis = new
BufferedInputStream(request.getInputStream());
                     bos = new BufferedOutputStream(new FileOutputStream(file));
                     byte[] bytes = new byte[bis.available()];
                     while(bis.read(bytes) > 0)
                     {
                         bos.write(bytes);
                         bos.flush();
                         bytes = new byte[bis.available()];
                     }
                 }
             }
         } catch (IOException e) {
             // TODO Auto-generated catch block
             e.printStackTrace();
         } catch (ServletException e) {
             // TODO Auto-generated catch block
             e.printStackTrace();
         } finally {
             if(bis != null)
             {
                 try {
                     bis.close();
                 } catch (IOException e) {
                     // TODO Auto-generated catch block
                     e.printStackTrace();
                 }
             }
             if(bos != null)
             {
                 try {
                     bos.close();
                 } catch (IOException e) {
                     // TODO Auto-generated catch block
                     e.printStackTrace();
                 }
             }
         }

         inputStream = new
ByteArrayInputStream("200".getBytes(StandardCharsets.UTF_8));
         return SUCCESS;
     }

     public InputStream getInputStream() {
         return inputStream;
     }

     public void setInputStream(InputStream inputStream) {
         this.inputStream = inputStream;
     }

     @Override
     public void setServletRequest(HttpServletRequest requestObject)
     {
         this.request = requestObject;
     }

}

--
Best regards,
Nikhil P kookkiri

Gtalk: nikhil.pk81
Skype: nikhil.pk81


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