Win a copy of Microservices Testing (Live Project) this week in the Spring forum!

Adrian Airmil

Greenhorn
+ Follow
since Dec 12, 2005
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Adrian Airmil

Paul Clapham wrote:Adrian, if you're still watching this: the charset mentioned in the mail headers has nothing to do with the charset of the individual parts. You didn't mention if the discrepancy you observed was an actual problem or just a curiosity.


Paul, this was an actual problem in Production. I have since figured out that the email body received is a sum of 2 parts of data. The first is entered by the user on the web page which is appended to the second which are some properties coded in a java class that does the actual email processing.

So the solution is two fold:
1) set the runtime variable on the server 'java -Dfile.encoding=ISO-8859-1'
2) set the right '-encoding' parameter when building the app to prevent the property value special chars from getting set to 'UFFFF' (unknown char)

So you are right, the charset in the mail headers weren't the issue.
12 years ago

Bear Bibeault wrote:You'll need to explain what you are trying to do better.


Sorry for the confusion. What 'submit' means is that the jsp has a form. The user will use it to upload an image. The form action will be set to point to 'imageResizer.php'. The php script will acquire the POST details from the jsp, process the resize and return a response of true if the resize was successful or an error.
12 years ago
JSP
I have a jsp which will submit an image to a php script. The script will resize the image and return true if it was successful or return and error. How can i catch the response from the php method and render the appropriate response on the jsp? The only way I can think of the redirecting from the php script upon completion to the jsp with a parameter in the url, doing a get and analyzing it to render the response in the jsp. Is there a better way of doing this?
12 years ago
JSP
Thanks for the clarification, Deepak. I've never had to use the -encoding flag before as well and hence all these questions

12 years ago

Deepak Bala wrote:There is no concept of choosing encoding at compile time. Encoding is always decided when the conversion occurs.


Really? I'm confused now. I received this advice : Special chars not being sent correctly in email
And since we are using Maven I was considering this : Specifying a character encoding scheme

But before doing that I wanted to verify if the -Dfile.encoding server setting was used for compliation of Java classes when the app is compiled on the server/unix box and hence this thread. If the answer is yes then I dont need to change any POM file to rebuild the app.
12 years ago

Deepak Bala wrote:

Does anyone know if this change means that this encoding is also used when the java classes in the app are compiled as well?



It would not matter if the encoding is applied at compile time. The option that you mentioned is the default one that is consulted when a program runs at runtime. More here -> http://www.jguru.com/faq/view.jsp?EID=78088

Did you mean to say runtime ?


No, I was referring to compile time. I de-compiled the class and the special chars, that are used in property values, show up as '\uFFFD'. Thus at run time they get rendered as a '?'. I was wondering if that default option also gets used at runtime. In that case I dont have to look into specifying encoding in Maven for the compilation of the app.
12 years ago
I dont work on servers but our server guy set the java start up options on unix as follows -Dfile.encoding=ISO-8859-1 and all the content coming from a form in a JSP is now being returned with the right encoding for special chars.

Does anyone know if this change means that this encoding is also used when the java classes in the app are compiled as well? or is it only used to set the encoding of the JSP's? Note: the app gets compiled on the server using Maven.
12 years ago
The app is compiled using Maven. I'll look into specifying encoding in the POM. Thanks for your response.
12 years ago
So I've decompiled the class file which was compiled on the build server and this is what it contains

All the special chars show up as '\uFFFD'. What is this and how do I fix it?
12 years ago
bump. anyone?

Would this have anything to do with file.encoding? The app is built on a server which then deploys the JAR to another server which renders the app. Setting the -Dfile.encoding=ISO-8859-1 on the server that renders the app has been done. Is the issue described above possibly occurring due to the fact that the file.encoding on the server that compiles and builds the app may not have it set to ISO-8859-1?

Seems like this is turning into a server question at this point.
12 years ago
The java class has the following:

The server has the following set

-Dfile.encoding=ISO-8859-1


When a user enters a message on the web page, the message is appended to the commentLabel & reportedDateLabel properties and sent as the body of the email. The special chars that are part of the message received from the web page are sent correctly, where as the property values defined in the above java class are not sent correctly. They show as a upside down '?' in the email body.

I have verified the headers of the email received and it does state charset="ISO-8859-1"

Is there something I need to do to encode the property values to be rendered correctly along with the message from the form?
12 years ago
Setting the charset for an email in my java class does not work. The emails get sent with a different charset other than the one in the code resulting in invalid chars.

When a user enters info on a form, an email is sent to a selected destination. When this is done through a weblogic10 server running on Unix, the result in the headers of the email received is:

Content-Type: text/plain; charset="ISO646-US"



Using the same application build, when i send an email from my localhost through a weblogic10 server running on windows, the result in the headers of the email received is:

Content-Type: text/plain; charset="Cp1252"



I dont understand why this is happenning even though the charset is being set as follows:



The charset ISO646-US results in '?' for all special chars. How can I set the charset to be iso-8859-1 for all content of the email? or is the code not written correctly.

Also would appreciate if anyone can provide any insight into why I get diff charsets when accessing the same java code running on 2 diff OS's.
12 years ago

Miklos Szeles wrote:Modify the method to public static void visitAllDirsAndFiles(File dir, int level) and the you can call recursively by
visitAllDirsAndFiles(files[i], level + 1);
You can print the tabs accordint to the level.


Thanks!
12 years ago
Thanks for your response

Miklos Szeles wrote:
You can check all the children and display the files first and only display the dirs after that.


So I've modified the code as follows and it works. Let me know if there are any errors.

result is:

Directory imagetest
Directory folder1
--->File folder1_img1.jpg
--->File folder2_img2.jpg
Directory folder2a
--->File folder2a_img1.jpg
Directory folder2b
--->File folder2b_img1.jpg
--->File folder2b_img2.jpg



Miklos Szeles wrote:Or you can add tabulators depending on the deepness so then the structure will appear corrrectly.


I'd like to do this. Could you give me some suggestions on how to do this?
>
12 years ago
I'm trying to show all directories and if a dir contains files i want to show all of them before moving on to the next dir.

I have a dir called imagetest. This contains a dir named 'folder1'. This contains 2 files (folder1_img1.jpg and folder1_img2.jpg) as well as 2 sub dirs folder2a and folder2b. folder2a contains 1 file and folder2b contains 2 files.

Currently testing this on my localhost but eventually it will run on unix.

consider this code


the results are:

Directory imagetest
Directory folder1
--->File folder1_img1.jpg
--->File folder1_img2.jpg
Directory folder2a
--->File folder2a_img1.jpg
Directory folder2b
--->File folder2b_img1.jpg
--->File folder2b_img2.jpg


which are correct. However if i rename 'folder1_img2.jpg' to 'folder2_img2.jpg', the results are:

Directory imagetest
Directory folder1
--->File folder1_img1.jpg
Directory folder2a
--->File folder2a_img1.jpg
Directory folder2b
--->File folder2b_img1.jpg
--->File folder2b_img2.jpg
--->File folder2_img2.jpg


This is not right as the renamed file now shows up under dir folder2b. Where as its location has not changed as it is still in dir folder1. I guess my process() needs to be cleaned up. Appreciate any help in listing the dir and files as per their nested locations.
12 years ago