Win a copy of Java EE 8 High Performance this week in the Java/Jakarta EE forum!

Emanuele Mazzante

Ranch Hand
+ Follow
since Jan 14, 2014
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Emanuele Mazzante

Hi Pete,
I'm very embarrassed to answer you. Only now I realize that, I do not know exactly why, the answer I had prepared was not successful. Surely for my carelessness.
Anyway, please forgive me. Thank you for spending time helping me. I'm very grateful.
All the best
1 month ago
Hi everyone,
I have a huge doubt and I can't find an answer. Through books and tutorials I learned that I need to provide different sized images for each resolution. In this way images appear the same across devices with different numbers of pixels on the screen. For example, an image in drawable-hdpi folder must be 1,5x greater than the same one provided in drawable-mdpi and so on. All of this thanks to Density-independent pixel system. That's ok can I choose the correct dimensions of my image source (base image)? Taking as example this layout from Material Design Guidelines:

Suppose the image showed has a fixed height and a width set in match_parent. I want to replicate this kind of layout with my own image. If I download an image from free stock photos website or take an image with my reflex, most probably I’ll get a very big picture, such as 5184x3456 px. I think an image like this is too big as source image. If I use such big image for mdpi drawable, the image for xxxhdpi drawable will be 4 times greater! Not to mention the weight!

I tried to do the following reasoning: a device like Nexus 5 has 1920x1080 resolution screen and it's classified as xxhdpi device. My idea is to resize the image to obtain a width equal to about the length of the longest axis, (y-axis, 1920px, because the device can be rotated). In this way I would have to obtain a lighter base image without a high number of unnecessary pixels.

Could you help me understand what the procedure is?

Thank for the attention
3 months ago
Thank you for your kind help but I granted the privileges to the user. I think the only solution in my case is to use a local DB like Derby. I hope I don't have to change too many sql statements.

Thank you to all!
I spoke with the sysadmin and he confirmed to me that they use a Microsoft proxy. Unfortunately he doesn't seem to have much knowledge of the subject but next Tuesday he'll give me a bit of time with him to do some test. In the pc at school I saw the options like showed in attachments. I tryed to uncheck the proxy but the connection to mysql db still doesn't work.
Now I would like to prepare one or more simple procedure to test next Sunday. In my program the connection object is created as following:

Can someone tell me how to adapt this code for that proxy?

One thing that sounds strange to me is that in my application there is a very simple scraper that it also doesn't work:

Could the proxy block also this kind of connection?
Thanks for your help

Dave Tolls wrote:Ah, well that won't solve that issue then.
You need to talk to the sysadmin and your tutor to get this sorted rather than trying to go around the current set up.

Ok, thank you. Tomorrow I'll try to contact the sysadmin to get the proxy address and proxy port.

K. Tsang wrote:Checking browser setting is one way. But of course you may not able to see it depending on your access right.

Thank you again, I'm quite sure that I haven't access to browser setting but tomorrow I'll check

Dave Tolls wrote:As a thought, do you have to use MySQL?
I was thinking, if this is to be pure desktop, maybe an in memory db, like Derby, would be OK.  That way there's nothing to actually install.

Thank you for your suggestion. It could be a solution, I didn't know that derby doesn't require to be installed. However my app has other online functions and the proxy could be a problem
Thank yor for your kind attention. Sincerely I don't. Is there a way to know that without asking to system administrator? Maybe via command line or using some simple exe without installing it.
Thank you again
Hi all,
I need to accomplish a project for final examination at school. My idea is to present a java desktop application for family management. All the information and expenses are stored in a MySql database. Unfortunately I don't have any administration rights in the computer at school.  This implies two main problems: I can't install neither the JVM nor the MySql database. To solve the first one, I download the JRE.tar.gz and ran the app through the command: start javaw.exe -jar myapp.jar, and it worked correctly. For the second one, I tried to use a MySql instance in my home server and also another MySql instance provided by Amazon Web Services. I tested my app in many computers of my friend and both the connection to MySql database worked correctly, but not in the computer at school. I receive error 2003 (10061). I'm quite sure to have granted the right permissions to the user so I was wondering if it could be a sort of problem with the school firewall. In both MySql instances I set the 3306 port. I have a very very basic knowledge of networking but I suppose that, when I try to connect to MySql, the server port is the 3306...but when the server send data to the client, which port in the client is used? Maybe it could be firewalled?
Someone can help me to understand the way to solve this problem? Thank you for the help and sorry for my bad English.

Amit Ghorpade wrote:I was trying to say the same thing, maybe my construction was poor. The intent was to clarify the fact that ${cookie} is a server side thing and only comes into play when server receives some cookies from the request.

Your construction was English and my servlet knowledge are very poor! Thank you again.

Bear Bibeault wrote:The cookies are created in the browser when the response gets to the browser. A JSP is executed on the server in order to format the response.

I've missed something and, according to me, my study book is not so clear about this fact. I hope to clarify with that article. Thank you so much.
2 years ago
Thank for your kindly attention.

Tim Holloway wrote:The server constructs cookies. Some cookies (such as jsessionid) are constructed by the server itself. Some are constructed by the web application program. They are all sent as part of the HTTP Response stream to the client (as part of the headers). The client then caches them and sends them back on the next and subsequent Request(s) - if any. Subject to the constraint that cookies come with an expiration date/time and once that expiration time has passed, the client destroys its copy of the cookie and no longer transmits it.

To better explain what was my idea about how the cookies work, I write the steps I thought they occurred when a client requests a web page:

1- the browser client contacts the web server for the first time
2- the web server creates a jsessionid cookie, put it into the response object and returns the requested page ( along with response object
3- the client catches the jsessionid cookie, stores it and then starts to render the page sended by the server
4- the jstl code into the index page reads the cookie in the browser client and show them in a table

Please forgive me if I wrote a big stupid thing...
Thank you again
2 years ago
First of all, many thanks for your kind reply.

Amit Ghorpade wrote:
When you first go to the JSP in your browser, there is no cookie created yet for the ${cookie} because the client has not yet sent any cookies to the server and ${cookie} will be evaluated at the server.
The cookies are created on the browser and that is why you can see them using browser tools.
On the form submit or page reload, cookies already created are sent to the server which are reflected in the variable.
To put everything in a dialogue, possible conversation would be as follows.

Maybe I misunderstood what is written in my book (Murach's Java Servlets & JSP): at first the browser requests a JSP or servelt. The servlet engine creates a session object and assigns ad ID for the session then the server returns the requested page and the ID for the session (which I suppose it's a cookie...). Reading that I thought that the server returns to the client the index.jsp along with JSESSIONID cookie so the the browser can render the page and elaborate the cookie.

Amit Ghorpade wrote:In my opinion, Coderanch takes pride in helping folks who want to know and learn, providing appropriate solutions and in a friendly manner.

In my opinion, Coderanch is a forum with the most kindly people (like you...) I have ever seen. It's not so easy to meet someone that take care of such a simply newbie question. Thank you again for the explanation.
2 years ago
Hi, I've made a very simple servlet/jsp to study how cookies work. During my test I saw a behaviour that I don't understand. In my index.jsp there is the following code to show all the saved cookie in my browser:

If a clean all the cookies in the browser and after start my application, that page doesn't show any cookie not even the JSESSIONID cookie. But if I open the Chrome settings, I can see that cookie. After reloading page I can see correctly that cookie.
In the same way, if I write some code in the servlet to add a simple test cookie, it's correctly sent to the browser but it's not showed in the table. To do that I have to reload page:

I think I'm missing something about how the the things work...
Could someone be so patience (...and excuse my bad English...) and explain me why this happens? Thank you for the attention
2 years ago
Hello Campbell and thanks for your interest.

I began to study the pattern with the Head first design pattern book and then trying to develop the program by following those patterns. Then I found other tutorials on the internet but sometimes the examples seem much different than the book.
For example, in this article the author recommends that you do not have relationships between the view and the model while in the book the view and the model have references to each other (like the observer pattern):

In the book the user's actions on the view call the methods of the controller unlike other tutorials where the controller creates the various Listener objects and passes them to the view (I understand that this may be a subtle difference).

Finally I saw that the rule of programming to an interface is rarely used.
I know that all tutorials and examples works but I'm trying to understand what is the recommended way for a good design.

Thank you for your help
3 years ago
I think is the right way, it's simpler and it also reduces the calls to the database. Thank you for the help.