Skip to main content

Posts

Showing posts with the label servlets

Respond encoding of Google App Engine(can not change response encoding)

public class FeedUpdaterServlet extends HttpServlet { public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { PrintWriter out = resp.getWriter(); req.setCharacterEncoding("utf-8"); resp.setLocale(Locale.TAIWAN); resp.setContentType("text/html; charset=utf-8"); resp.setCharacterEncoding("utf-8"); resp.getWriter().println("Hello, world!!@!"); out.println("我是人"); //some chinese character out.println(resp.getCharacterEncoding()); out.flush(); out.close(); } } web xml <locale-encoding-mapping-list> <locale-encoding-mapping> <locale>zh_TW</locale> <encoding>utf-8</encoding> </locale-encoding-mapping> </locale-encoding-mapping-list> Output: Hello, world!!@! ??? ISO-8859-1 It seems that the encoding of the respond can not be changed, what is happening???

browser keeps on looking for the data but never fetches it

Following is a snippet that is meant to fetch the data from the database. But when i click the submit button to see the data, the browser keeps on looking for the data but never displays anything (the browser doesn't show the next page but keeps on looking on the same page) . I don't know what the problem is. Snippet that fetches the data : public void doGet(HttpServletRequest request,HttpServletResponse response) throws IOException,ServletException { try { Context context = new InitialContext(); DataSource dataSource = (DataSource)context.lookup("java:comp/env/jdbc/MyDatasource"); Connection connection = dataSource.getConnection(); String sqlStatement = "SELECT * FROM INFORMATION"; PreparedStatement statement = connection.prepareStatement(sqlStatement); ResultSet set = statement.executeQuery(); PrintWriter writer = response.getWriter(); response.setContentType("text/plain");

jquery validation engine : ajax field validation with java (not with php)

I try to validate a field with ajax and a function which verify that the value is not already in base. All examples I found are with php ; how to do with java ? JSP code : <form id="FLoginNew" action="Loginnew" method="post"> ..... <script> $(document).ready(function(e) { $("#FLoginNew").validationEngine('attach', {promptPosition : "centerRight", scroll: false, validationEventTrigger: "blur", autoHidePrompt:true, autoHideDelay:3000 }); }); </script> jquery.ValidationEngine-fr.js altered : "ajaxLoginCall": { "url": "myapp.selvlets.DoublonLoginServlet", "extraDataDynamic": ['#login'], "alertText": "* Ce login est déjà pris", "alertTextOk": "* Ce login est disponible", "alertTextLoad": "* Chargement, veuillez att