Today I had a problem with Tomcat encoding with query params.I have solution for search entities.It was working with latin words. But when I tried to add query params in cyrillic, tomcat treat them as unreadable symbols, despite the fact, that I have URLEncodingFilter in my web application, that encodes everything in UTF-8,
So, request like this turns to be invalid.
So, as usual, I started investigation of this issue. First, I scanned my project, especially web.xml deployment descriptor for some unusual encoding thing, but I failed, I found nothing. So I delegated all the investigation to google, and found that I should edit my
You need to find Connector with port=”8080” and add two lines.
<Connector port="8080" protocol="HTTP/1.1"
useBodyEncodingForURI="true" <!-- This line -->
URIEncoding="UTF-8" <!-- This line -->
Restart your tomcat, and now everythig will be okay
Before writing this post what I want to underscore is that this port is mostly for middle layer developers, that don’t now many things about database. Around year ago I started to work on some freelance project.I tried to use all up-to-date technologies: Cool web framework Spring with DI(Dependency Injection), ORM framework by java persistence api(JPA) specification, simple MySQL database. I decided to make RESTful service, and, in the end, I had 20+ methods there.I finished my part of project and delegated another one to other people. The reason I am writing this post is that application had one BIG ISSUE, that I understood recently: It did most of the db logic in the middle layer. Yes, all compatibility checks, some data validation and other staff were done in my web service. I would like to emphasize why It is bad: There is a chance that somone will use your database beyond your application, for example, someone will insert invalid row.Then there is a big risk that your application will broke it’s constistency - some data will now be invalid or broken. That’s why I make a conclusion that when you are choosing where to store your logic - in...
How many times did you have to use java enums in your JPA/Hubernate entities ? Yes, instead of having some relations with reference-tables, which are some sort of dictionaries, you wrote simple field with varchar type Something like class Model with RowStatus enum RowStatus is used to detemine whether row is deleted from the system, or row is active.It seems, that this should be enough to have no problems while using this functionality. But there is one potential problem: When we set enum in our system, we made a contract, that we will send only values from RowStatus enum. But how about updating data outside our system ? For example, system administrator of your database made some critical update and committed some critical bug - instead of values from RowStatus - ACTIVE, DELETED he updated row with syntax error - DELITED. From now on, when Hibernate will try to map such row - he will throw an exception. That’s an issue. Possible solutions ? The only solution that I can offer you is that you will controll adding your data on database. You can use database enums, constraints, triggers, etc… I choosed postgres enums. To add such, you simply need...
How many times did you experienced issue, when you need to clean your database from unused data ?For example, you have a qa server with thousands of rows, which you don’t need anymore, so it’s time to delete them. To clean up your database, someone call separate scripts for each table, someone create-drops database.I decided to delete all tables. To remove all rows, you can use maven sql plugin, which has powerful possibilities for doing work with sql. First of all, if you have your maven application, I would reccomend to create separate module for sql. If you don’t want to do this, just leave it as it is in your root pom.xml. You will need to add Maven Sql Plugin. Then, you need to map execution to install goal. You will need to create resource folder.This will be the place, where you will store your scripts. Before we start I don’t want anyone to think, that such module is the best place for storing your database schemas creation.For this purposes there is a good framework called liquibase - it saves migration history and can surely know, what should be updated, and what should not. Such module is always good...
I’m sorry, but I don’t want to be an emperor. That’s not my business. I don’t want to rule or conquer anyone. I should like to help everyone - if possible - Jew, Gentile - black man - white. We all want to help one another. Human beings are like that. We want to live by each other’s happiness - not by each other’s misery. We don’t want to hate and despise one another. In this world there is room for everyone. And the good earth is rich and can provide for everyone. The way of life can be free and beautiful, but we have lost the way. Greed has poisoned men’s souls, has barricaded the world with hate, has goose-stepped us into misery and bloodshed. We have developed speed, but we have shut ourselves in. Machinery that gives abundance has left us in want. Our knowledge has made us cynical. Our cleverness, hard and unkind. We think too much and feel too little. More than machinery we need humanity. More than cleverness we need kindness and gentleness. Without these qualities, life will be violent and all will be lost…. !/images/photos/0000/0874/Great_Dictator_Pub_140-6_normal.jpg! The aeroplane and the radio have brought us closer...