Tomcat-Https Post-File Upload-Parameters become null - java

I am trying to create a simple https service which allows an end user to upload a file to my system. I am using the HttpRequester plugin in firefox to test this service.
My code seems to work (file data reaches the server) when the files I am uploading are less than 1MB in size but does not work (request.getParameter(file) returns null) when the file size is larger than 1 MB.
After some googling around I changed some parameters in server.xml
<Connector port="21003" maxPostSize="0" maxHttpHeaderSize="0"/>
But still no luck.
Any idea of what I could try next? Any help would be much appreciated

Related

How to edit /etc/hosts file to open angularjs springboot project in specific website address

I have an angularJS application with springboot and it runs on 8090 port number with "index.htm" file. Like below ;
192.168.1.25:8090/index.htm
I just googled about the changing port and I did the change with 80 port number so I can open the web page with
192.168.1.25/index.htm
But, in google there are plenty of angular result and they tell me to change those settings with in angular.json file. I created a temporary angular project and did those with successfully. But, I could not figure out about the angularjs part. I checked the project and I could not find any file like angular.json. After that checking the springboot, I found this part of where I can open the web page with the above second URL address ;
192.168.1.25/index.htm
The code of Spring Boot part is below (There is where I can change the port number) :
Those ones did the trick by the way.
config.getMemberAttributeConfig().setStringAttribute(ServerService.MANAGEMENT_URL_PREFIX, ":80/index.htm");
config.getMemberAttributeConfig().setStringAttribute(ServerService.MANAGEMENT_URL_PREFIX, ":80");
After those steps, I can easily serve my angularjs app on 80 port and start to thinking about editing the /etc/hosts file on the server machine as :
192.168.1.25/index.htm xyz.com
I did reboot when I finished the editing part and I tried again to write xyz.com on firefox browser it does not go to my application.
I am still looking on the google and still could not find any solutions about this problem.
Any help will be really appreciated.
Format for hosts file is
#<ip> <hostname that resolve to the ip>
192.168.1.25 xyz.com
# or a list of names
192.168.1.25 xyz.com myapp.xyz.com
You do not put any port numbers or path parts in it. This will obviously only work if you edit the hosts file on all the computers
you are indending to access the site from and not necessarily on the host running the application itself.
That being said, you should probably read on supported Spring Boot properties because starting an application server on a specific port should be as easy as adding application.properties file in java resources with the following line:
server.port=80

OneDrive download session maximum time

I am writing a program which calls OneDrive REST api to download some files (total 12G) using java on the uri:
GET /drives/{drive-id}/items/{item-id}/content
And the inputstream is closed (socket reset from server) before the end of file transfer, causing the file download failed.
I tried to put the same request in chrome and firefox, same problem also appears.
Now I know that I cloud use partial download by adding the range header to the http request(and it works like a charm):
Range: bytes=0-1023
But still, I wonder what is the maximum download time/size that will trigger the close of the connection?

Apache server repeatedly spinning if I try to retrieve files or check if folder exists

I am creating a micro service where my application will go to Apache Server to get files and folder-contents.
Not all the time, but very frequently, my Apache Server just spins when I try to see if file/folder exists:
return (con.getResponseCode() == HttpURLConnection.HTTP_OK);
or when I try to open connection:
c = (HttpURLConnection)url.openConnection();
And I end up restarting service.
I can clearly access it by entering URL manually and get a 200 response code.
I configured Apache to allow Index view for these files and folders.
Sometimes, when I type full path to a file using IP address, it spins also.... I find this very strange.
I don't know why this would happen... Any ideas?
Version: 2.4.23 win64 VC14

SFTP via JSch is throwing error 4: Failure

I am facing a peculiar issue while trying to SFTP a file from Windows to Unix server. The error "stack trace" is -
4: Failure
at com.jcraft.jsch.ChannelSftp.throwStatusError(ChannelSftp.java:2846)
at com.jcraft.jsch.ChannelSftp.checkStatus(ChannelSftp.java:2459)
at com.jcraft.jsch.ChannelSftp._sendCLOSE(ChannelSftp.java:2465)
at com.jcraft.jsch.ChannelSftp._put(ChannelSftp.java:683)
at com.jcraft.jsch.ChannelSftp.put(ChannelSftp.java:475)
at com.jcraft.jsch.ChannelSftp.put(ChannelSftp.java:365)
I have searched a lot on other forums but could not get to the root cause. I have observed one more thing - the file name, I am trying to SFTP, is *.xml when I change it to *.XML the SFTP is "successful". Very weird could not identify the issue. I am trying this using JSch Java API. But I have seen the same issue while trying the WinSCP front end.
It is common for OpenSSH SFTP server to return code 4 (Failure) for many different reasons, without giving any details.
You would have to check SFTP server log to find more.
Though the most usual cause is a lack of free disk or user quota space – Which can usually be identified by the file being created with zero size.
i was facing the same issue. was puzzled then i realized there was a space issue on the server folder. Please do check the server available space.
command: df path to the folder
I was facing the same issue. Please make sure that your SFTP service is running. And If it is already running then restarting this service should do the trick.
I had the same issue. Tried everything, turns out I had set the timeout to what I thought was 30s but it was actually 30ms. Changing it to 30000ms solved the issue.
session.setTimeout(30000);
I've seen this error and the cause in my case was, the uploaded file names weren't supported by the file system used by the SFTP server.

How to make client load new html page with new java applet

How can I make the browser of a client load the new version of the html page with a new java applet?
We updated a system in the field, but when the client connected to the web server, the old java applet was still shown (from the cache).
How can I force (preferably from the server side) the client to load the new version instead of the one from it's cache?
Old system (before upgrade) :
old linux version (more than 10 years old)
old apache webserver (more than 10 years old)
old java applet (separate class files) (about 2 years old)
old index.html in webserver root dir (about 2 years old)
New system (after upgrade) :
same IP address and port as the old system
windows xp embedded
apache/2.2.21 (win32) webserver
new java applet in jar file (all different class names from the old version)
new index.html in webserver root dir
The user is using Chrome on a Windows XP machine
When the user loaded the page in Firefox, the new java applet was shown and working flawlessly. (He never loaded the old java applet in firefox)
[EDIT]
adding the lines from looper to my httpd.conf did not lead to any errors, but i am not sure if it works either ...
i don't seem to be able to reproduce the caching problem of my client : when i change something the in the applet and load it again from another computer, then nothing changes, but when i reload a few minutes later, it does show the new version .. without or without those extra lines with CacheDisable
when i search my httpd.conf for "cache" then all i find is :
#LoadModule cache_module modules/mod_cache.so
#LoadModule disk_cache_module modules/mod_disk_cache.so
#LoadModule file_cache_module modules/mod_file_cache.so
#LoadModule mem_cache_module modules/mod_mem_cache.so
so it seems no caching is enabled ?
when i add the line with CacheDisable by itself (without IfModule), then Apache doesn't want to start, so it probably corrupts httpd.conf ?
[EDIT2]
as the server OS, web server, java class names, and all filenames except index.html are different from the old version, it must be the cached index.html which is the cause of the problem.
I added the meta tags from FrancescoMM's answer to my index.html, and hope this will prevent the problem for future releases
If the java classes are different, then the index file is the one that is in cache. It could also be the client proxy cache, so acting on the server has no result.
The fastest solution is to send a new url to the client:
http://www.site.com/index.html?random_param=1234
http://www.site.com/?random=1234
http://www.site.com/?1234
http://www.site.com/?new
or even just
http://www.site.com/?
should be enough.
EDIT
Also, have you tried adding all the pragma no cache and expiration date meta tags to the HTML page? That should tell the client proxy to reload the page anyway.
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
<META HTTP-EQUIV="EXPIRES" CONTENT="Mon, 22 Jul 2002 11:12:01 GMT">
Note that EXPIRES is set to an old date on purpose. This may not solve your problem this time, as if the new index is not loaded, nobody (server, proxy, client) will see the new tags, but will make sure the next time the page is loaded every time.
Unless you put functionality that allows the applet to invalidate itself based on a server instruction, you'll have to do reset from the client side. Clearing the cache on the browser should do, from the information provided. Every browser has a way of clearing its cache. I don't believe there's a shorter way than that.
Every system turns into a legacy system the moment it's first deployed. It's always a good idea to plan for upgrade. At the very least, any applet that does server communication should report its version number to the server, enabling the server to reject service, start upgrade, notify the user, or whatever else is appropriate.
Just force no-cache in Apache in the httpd.conf.
From the apache-docs:
<IfModule mod_cache.c>
CacheDisable /local_files
</IfModule>
Instead of disabling cache for all local files, you can specify the complete path to the applet-file.

Categories

Resources