I am building an application using spring mvc and jpa using jboss7 and mysql in eclipse ide. I am having a strange problem. All my jsp pages are encoded with charset: utf8, which I think is working correctly. But whenever I try to post a data from the jsp to the controller, my data gets encoded with a different encoding style. I tried to look for the header using firebug and was astonished to see that the post request has a header with content-type : "text/plain;charset=ISO-8859-1". I have already configured the SetCharacterEncodingFilter for UTF-8 in my web.xml (it is the first filter). But still the problem exists.
I also set "org.apache.catalina.connector.URI_ENCODING" to value="UTF-8".But in vain .
Also I have added bean messageSource with property defaultEncoding set to "UTF-8".
<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource" >
The problem still exists. Please help
Thanks in advance.
The request header is set by the browser, so your application can't control it. Usually, in your HTML form you could put an accept-charset=utf-8 attribute to specify the encoding, but that doesn't necessarily work. See this question Setting the character encoding in form submit for Internet Explorer.
you should need to set the encoding of the JVM like follow :
-Dfile.encoding=UTF-8 -Dfile.io.encoding=UTF-8 -DjavaEncoding=UTF-8
thus there wont be any doubt at all.
Related
I am new in Java EE and I am building a web application with maven, spring mvc
and hibernate.
I have a problem with the jsp. I can not show the data of object with the expression / jstl
language. In console doesn't show any error. Any suggestions?
Pom.xml:
Controller:
Inicio.jsp:
I guess in the controller you are setting the object with key
model.addObject("usuario", usuarioo);
The first character is small 'u'.
And in your jsp you are trying to access using Usuario. Thus the value is not getting printed.
Kindly use something like
${usuario.nombre}
I met a problem, I want to set the tag of security-constraint according to my configuration file dynamically, but I can't do it. So I hope tag in web.xml can be dynamically generated or written outside web.xml. Thanks a lot for your help!
I think your question could be related to this one. However, if you were working with Servlet 3.0 spec, you could try the approach of programmatically adding and configuring security for the servlet, as shown here.
I have a 3rd party .jsp that I am trying to use in my SpringMVC 3.2 application.
the URL call looks like this:
http://localhost:8080/dms/pcc.jsp/Page/q/0/AttributescumentID=eJQAyAEYASgBJAFMAMgAlADIARgBsAG8AZwBvAC4AdABpAGYA0
I am getting a 404 error. How do I map this in my web.xml?
when I call
http://localhost:8080/dms/pcc.jsp
it works (well, no 404 errors) but I need to send it the parameters.
Changing the 3rd party jsp might be problematic, so how does one map this call straight to the jsp?
Thanks in advance.
Really a broad question. I would start with checking mapping in #Controller, then move into application-config.xml and then web.xml.
It would be nice if you would look at sample Spring Application.
If call to http://localhost:8080/dms/pcc.jsp works, you should try following thing.
http://localhost:8080/dms/pcc.jsp?AttributescumentID=eJQAyAEYASgBJAFMAMgAlADIARgBsAG8AZwBvAC4AdABpAGYA0&otherParams=something
The Page/q/0/ part in URL seems to be messing things up for you. If these also are parameters to be sent, send it the way explained above.
I am building a Spring MVC web application that uses JSR-303 validation. With the first form I created, I added a couple of validation annotations (including custom error message codes) to the form backing bean. I also created ValidationMessages.properties and ValidationMessages_en.properties files.
Everything seems to be working correctly with one exception: multi-byte utf-8 encoded characters are not displayed correctly (e.g., "ñ" is displayed as "ñ").
This is not a problem with my standard messages.properties and messages_en.properties files that I use for field labels and other text, so I'm assuming it's an issue with the hibernate validator code. Has anyone else had this issue and solved it? FYI, I'm using Hibernate version 4.3.0.Final.
Thanks,
Peter
In my properties files I must include special characters like this:
\u00F3 instead of ó
In that way they are shown well.
Hope it helps.
P.S.: Using ResourceBundleEditor from Eclipse also helps.
I'm looking to disable jsessionid from being used in the https headers.
Is there a way to turn this off or disable this being set as a cookie in tomcat 7?
I either want the jsessionid to arrive embedded into a GET method url name value pairs or to be part of a POST request name value pairs.
I know all the advantages and disadvantages of using cookie based sessioning and url rewriting but I have specific needs for specific impl of restful web services.
I need tomcat 7 to accept jsessionid without using the http header: jsessionid.
Thanks.
UPDATE:
so I looked around some more and found this which is implemented using the web.xml conf.
However the following doesn't seem to work with Tomcat 7.
<session-config>
<tracking-mode>URL</tracking-mode>
</session-config>
is it a case of TC7 not fully implementing the servlet 3.0 spec?
The web.xml setting works for me with Tomcat 7.0.20.
Log and check the effective (and maybe the default) session tracking modes:
logger.info("default STM: {}" , servletContext.getDefaultSessionTrackingModes());
logger.info("effective STM: {}" , servletContext.getEffectiveSessionTrackingModes());
Maybe your app override somewhere in the code the session tracking modes. An example:
final Set<SessionTrackingMode> trackingModes =
Collections.singleton(SessionTrackingMode.COOKIE);
servletContext.setSessionTrackingModes(trackingModes);
Check ServletContext.setSessionTrackingModes() calls in your code.
It's also possible to set default session tracking modes in the Tomcat's context settings but I found that web.xml settings override them.