Karol Matysiak

Greenhorn
+ Follow
since Aug 30, 2012
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
1
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Karol Matysiak

Hello.

I'm using JAX-WS web service which stands on tomcat6 server. I want to upload and download files through the web service. Since 2 weeks I saw many examples, I have read alot of posts and nothing worked. I think that the best way to send those files would be MTOM, but I don't know how to implement it. I tihnk that I have read almost everything but maybe somebody knows where is good example how to do this? It can use soap attachments or mtom or anything else, but it should be able to transfer various files as pdf, doc, images.

Best Regards.
5 years ago
Hello.

I have a jsp form. When 'send' button is pressed it should go to the Servlet. Servlet should do his magic and dispatch and forward the list attributes to the next jsp page. But when i'm pressing the send button, I'm only redirected to the Servlet (in the address bar it's the address of server, not the jsp page). I don't want to use response.sendRedirect(), is there a way to do it with RequestDispatcher ? I want to be redirected from the jsp page with the form to the other jsp page, but the servlet should also perform his magic somewhere between the form jsp page and the other jsp page.
5 years ago
so the only way is to use framework? And most of website which are JSp/Servlets based uses frameworks to build pages based on template?
5 years ago
JSP
Hello.

I'm think about building website with some kind of classic template.

I could do this with jsp:import, but that would mean that i have to paste few lines (header part, with title of the page param, banner/menu part and footer part) in each page and I would have to override the "content" part, and I think this is not exactly the idea of so called "templating". I know that in JSF is something like ui:composition, and I'm looking for something like this, but using JSP and servlets. Is there any jstl tag to do this, or maybe I should use framework like spring or struts?

best regards
5 years ago
JSP
Sorry for double post, but I have to update few things. So:

I have switched to linux, now I have mysql server 5.1, jboss 7.1.1, eclipse ide.

MySQL encoding is now set to utf-8 and I have polish characters in linux command line, but of course i don't have those characters on my web page, and not only in data retrived from database, but also on template text in jsp, also in title of jsp. Everything is the same but it's of course doesn't work...

Any ideas what can be wrong now?
5 years ago
JSP
Yes, I'm using windows console.

Ok but if I set encoding to latin2 - in windows console I have all characters which I want, when I will change it to utf-8, those characters are missing.

Anyway, like you said, I wrote simple app that is connecting to the same server as my JSP, and still the polish characters are not displayed :|
5 years ago
JSP

Paul Clapham wrote:
You can't just change the configuration and expect it to work correctly. All that does is to assert that data which was already encoded in latin2 is now encoded in UTF-8.
Which of course it isn't. You have to export all the data from the database to a text file, then change the configuration, then import all the data back from that text file.



Of course your're right, but I have even created new database to check it, without any success. In best configuration I had something like that on my server:
query:
result :



+----------------------+-----------------+
| Variable_name | Value |
+----------------------+-----------------+
| collation_connection | utf8_general_ci |
| collation_database | utf8_polish_ci |
| collation_server | utf8_polish_ci |
+----------------------+-----------------+



Also it was set everywhere utf8_general_ci, and still no polish characters
And result for query


Result was:

+--------------------------+----------------------------------------------------
-----+
| Variable_name | Value
|
+--------------------------+----------------------------------------------------
-----+
| character_set_client | utf8
|
| character_set_connection | utf8
|
| character_set_database | utf8
|
| character_set_filesystem | BINARY
|
| character_set_results | utf8
|
| character_set_server | utf8
|
| character_set_system | utf8
|
| character_sets_dir | C:\Program Files\MySQL\MySQL Server 5.5\share\chars
ets\ |
+--------------------------+----------------------------------------------------



And I have also created db in InnoDB engine, with setchar=utf8 attributes, I created even tables with encoding set to utf8 - and still it didn't worked. I was searching solution for few days, and the only thing i found was for PHP developing to send mysql query "SET NAMES 'utf-8' ". Here's my.ini file:


[WinMySQLAdmin]
Server="C:/Program Files/MySQL/MySQL Server 5.5/bin/mysqld.exe"

[client]
default-character-set=utf8

[mysql]
default-character-set=utf8

[mysqladmin]
default-character-set=utf8

[mysqlcheck]
default-character-set=utf8
[mysqldump]
default-character-set=utf8

[mysqlimport]
default-character-set=utf8

[mysqlshow]
default-character-set=utf8
[mysqld]
character-set-server=utf8
collation-server=utf8_polish_ci
init_connect='SET collation_connection = utf8_polish_ci'
init_connect = 'SET NAMES utf8'



5 years ago
JSP
My mistake, it should be "work". Now it's ok;p
5 years ago
JSP
Nope, it still doesn't work. Only records which I add from the mysql server console display without polish characters.
5 years ago
JSP

Vishal Shaw wrote:
Did you mean, you are trying but can't set it, or you have been forbidden to set it?



Yes, I tried, it's not any buisness project so I can set up what only I want, but I have set up everything to utf-8 in my database and polish characters wasn't displayed well.

Vishal Shaw wrote:

I think your filter is encoding only request parameters not the response object. So, you can try setting it on response objects too, alternatively try adding

in your HibernateTest.java



I will try to add this when I will be at home.
5 years ago
JSP

jatan bhavsar wrote:Hi Karol,

Try to work this way and let me know what type of error are you getting i might be able to help you.
Also have you set the UTf-8 encoding type for the glassfish server like <parameter-encoding default-charset="UTF-8"/>.



I don't get error. Data is displayed, but I've got something like Imię: Andrzej Nazwisko: Krokosiäski tel.: 721265273, instead of Imię: Andrzej Nazwisko: Krokosiński tel.: 721265273 . Word "imię" got polish character, but that word is not from the database.
I just notice, that I didn't changed the filter. After change (it's now encoding to latin2, same as mysql server) the data which was in the database is displaying as earlier - Krokosiäski, but when I will add somethign through the form on index page, everything is fine (it displays Krokosiński ).

This is wrong, as UTF-8 is the most accepted encoding, until unless you want to use UTF-16 :)



I know, but I can't set up my db server to utf-8 :/ I'm trying this since few days.

As for the character encoding filter, is it the first filter (in the filter chain) in your xml? Otherwise it will not work as intended. Also did you tried setting the connection encoding to the required encoding, like

I did it for UTF-8, you can use your encoding , if you desire.
Also is your page encoding using the required one, or is it using the default one?

Try these and let us know.



I have that in my hibernate.cfg.xml - but it didn't solved my problem. Of course in each page I have set up encoding to latin2.
And about my filters, I have only that one filter, so it must be first and the last filter in the chain :)
Here is my hibernate.cfg.xml

hibernate reveng.xml

JSP with the form

JSP with the data from db

servlet


I don't post the java mapping file because it is a bunch of setters and getters.>
5 years ago
JSP
Hello.

So:
I'm using windows 7 (sadly),
I've got MySQL server with database encoded to latin2
I've got glassfish3 server with hibernate (3.2.5 ? or something like that, I can't check it exactly right now)
I'm using JSP/Servlets to create webapp

When I select data in my mysql console, everything works great, I have a polish characters, but when I want to retrive data from the db and put it into the JSP page, data displays without polish characters. I have set the encoding to latin2everywhere I could (jsp pages, hibernate.cfg - also in the hibernate.connerction.url property, filter), but without any success.

I had a problem with displaying the polish characters in the page title, but when I have added a filter (found on the net) everything was fine, but the filter changed encoding to UTF-8. So I have also changed it to latin2 encoding.

When I set utf-8 in my mysql database I don't get polish characters when I'm selecting data, so I can't use utf-8 ;/

Do I need to change encoding somewhere else? In glassfish server or jdbc driver?
5 years ago
JSP
ok so one and the last question. I have a jsp page with a form, which is for example registration form ( It should send data (which are of course validating before sending it) . I also have a servlet called DbCon.do which is responsible for connecting to db, and second servlet called PreparePage.do which is responsible for preparing data to the output JSP page and for dispatching the request. And my question is, which element should be in action parameter of the form ? DbCon.do? or PreparePage.do?
Ok so if I understood those articles right...

JSP pages are jsp files (which are really a servlets) which are responsible for generating html pages. They use EL to get the data from servlets or helper class (java classes).
In each web app we need a servlet which is responsible for connecting to the model, for example servlet that retrives/updates/deletes data from database. This servlet also puts retrived data in the request.
Second servlet gets the request and the data which was in it and prepare it for the "final" JSP page. It also redirect (using dispatcher ?) the request to the "final" JSP page.
Final JSP page gets the data from request and generate dynamic content.

Am I right?
I still don't get it what you could do in a servlet ? Most of things you can do in normal java helper class. In servlet of course you can make a lot of "initialization things" like connection to database, but I don't understand what to put there more? For handling request and response?