How to disable file upload in struts 2? - java

My we application is facing constant intrusions. It is hosted in windows server. I have posted my issues here before.
I have also update all the jars, but with no results.
Now what I found is that some unwanted files are upload uploaded in the server, which takes 100% CPU or making unknown activities to the server.
I guess they are uploaded from my web application of struts2. Jboss console is provided in details here. Now my question is if there is any way to stop uploading files via struts2
Thanks in advance

Related

How to upload jar files in webswing?

I want to convert my Swing application to web application. Getting help from How to deploy swing application on web browser?
Please have a look to second step of first answer ("Install this [AjaxSwing] application in your system"). Where can I upload jar file and how?
You don't actually upload a jar file, I think the related answer is misleading. Webswing is a software you download and install on-premise. It starts a web server which serves your application on a web page. All you need to do is create a configuration where you specify the path to your jar file. As Gilbert pointed out, you can get the idea when you read the Webswing documentation https://www.webswing.org/docs/20.1/start/quickstart.html

Where to upload an image/file to make it appear on HTML?

Well,I'm working on an Eclipse Dynamic Web Project under Tomcat.
I'm trying to make a web application/site.In a jsp/html page,there is a form where a user can upload a photo.
I handle then this action from a servlet that has to store this image/file somewhere so as to make it possible the image appears whenever I want on the site.
Here is the problem.I started by storing it on my file system,(path in a database) but when I wanted to retrieve it the page didn't appear.
I guess the reason is here:
Why can't I do <img src="C:/localfile.jpg">?
Then,I tried to store the file in the eclipse project folder(WebContent/folder) where I've stored manually some images that do appear.
File folder=new File("/TED/res/img");
File file=new File(folder,fileName);
System.out.println(file.toPath());
Files.copy(fileContent, file.toPath());
But this exception happens:
java.nio.file.NoSuchFileException: /TED/res/img/2017-08-13-123524.jpg
It's one the line of files.copy command which means that
new File(folder,fileName) that I tried failed
What should I do? From what I've read,I understood that also saving file in the IDE's project folder is also wrong but what other choice do I have?
Ultimately, the project will be deployed to a server. As such, there are three distinct issues:
Uploaded user content location: content like images should be uploaded to a folder outside your web app (project). Images inside the web app (project) should be those that are necessary for the application and provided by the developer, not user-generated.
In Eclipse, during development and testing, you will want to serve these images through Tomcat. There are many ways to do this. Tomcat configuration is probably not the best for this - please read the answer and discussion here: Simplest way to serve static data from outside the application server in a Java web application
Once the application is deployed to the server, Tomcat will most likely run behind a Web server like Apache or Nginx. In this case, the external image folder and its contained files can be served directly by the Web server. Even if you implemented a servlet in (2) for local testing with Eclipse and this servlet is part of the code that is deployed, it will not be invoked as the URL will be intercepted by the Web server before it reaches Tomcat. For example, if your uploaded image folder is C:\images on your development environment, it can be served by the servlet using the technique in (2) as /images/*. When deployed to a server, the Web server can be configured to servet /images/* from /srv/content/images and this request will never reach Tomcat.

How to deploy/upload a JSP file on Server

I have created a jsp file which will give an output in JSON format using java class and servlet, i am new to java and i don't have idea about the deployment of jsp file. Can anyone suggest me how to do it? I used to develop an asp.net web application in which there was a specific option available which called " publish project", but i cant find in eclipse.
I already have a php server in which i have uploaded few php files, can i use the same server to upload this file?
Currently, my application is running fine on localhost.
Please help me with this matter and thank you for your time.
To publish your project in Eclipse:
Right click your project
Export
Under Web > Choose WAR
Then just follow the instructions and your good to go.
It is done as a component of a WAR (Web Application Archive) file.
Upon deployment, JSP files are processed by the Servlet container. The processing effectively turns them into Servlets, such that the plain text of the JSP becomes println statements in the response of the Servlet, and the embedded Java code in the JSP becomes regular Java code in the Servlet.
The packaging details are covered in detail in the JEE7 tutorial, although earlier tutorials don't differ much in the details.
i assume you are using tomcat in your php? you can use tomcat or glassfish server to deploy your application. you just need the .war file of your application and upload it to the admin page of tomcat or glassfish server.
It should be in .war file format
Here are few links which can help you in building it from eclipse, link1, link2.
For deployment, there should be a server -- tomcat / glassfish / jboss which can provide platform to execute .war files.
IDEs and .war files are great productivity tools, but I'm of a mind that you need to understand how these things work from the command line. I'm using Apache Tomcat running on a Raspberry Pi as a development server. I developed my .jsp and then just copied to where it needed to be. In this example login.jsp needs to be in the root folder of an app called SEM. So, just copy it there and access it via its URL.
sudo cp login.jsp $CATALINA_BASE/webapps/SEM
http://localhost:8080/SEM/login.jsp
Didn't even have to restart Tomcat. :)

Client based solution for upload entire folders to an Servlet

Im currently writing a web application, where a user should be able to select an folder and upload all of its content to an servlet.
The idea is, that a user can select a folder, the folder and its content will be sent due a post request to the servlet. The servlet takes them, parses the structure and saves the structure in a database. (Filenames , foldernames..etc) (Thats also why, i cannot pass the files directly to the ftp server).
Afterward the servlets connects to an FTP Server, where the files will be stored permanently.
The Web Application uses JavaEE (Apache Tomcat 7.0, Servlet 3.0 API)
Currently Im using JUpload to achieve this, but in fact I've read that it is highly advised against using Java Applets, because of security issues. Also JUpload is not intended to use with Servlet 3.0 API, but with a little hack it works.
A normal input file form is not sufficient for this need.
Now I'm wondering, because i didnt find any other solution, which can achieve this. I've heard about some Flash Solutions, but im not familiar with flash. And also Flash has some security issues, like Applets.
Is there any other solution to solve this ?

Downloading large files from alfresco

I am working on Alfresco Web Content Repository. I am writing a portal application which uses alfresco web service api's to communicate to alfresco. I am writing code to download files from alfresco to local system. I am using PortletOuputStream as an output stream and using jboss Gate in portal as a portal server. But when i am downloading large files(greter than 63M) i am gettin Heap space error.
This problem can be solved by increasing jboss heap space.But i want to do without increasing that. Though i am reading in chunks i am getting this error.
Kindly let me know how to solve this
Thanks in advance

Categories