java - how to Encode and decode text in Jsp -


<%@page import="java.net.urldecoder"%> <%@ page language="java" contenttype="text/html; charset=iso-8859-1"     pageencoding="iso-8859-1"%>  <%@page import="java.net.urldecoder"%>   <%@page import="java.net.urlencoder"%> <html> <form action="index.jsp">     <body>         first input:         <input name="firstinput" type="text" name="fname">         <br>         <input type="submit" value="submit">          <%             string first = request.getparameter("firstinput");               string searchtext=urldecoder.decode(first,"utf-8");             out.println(searchtext);              out.println(urlencoder.encode(searchtext,"utf-8"));         %>   </body>  </form> </html> 

this code want encode , decode text in jsp actully want when input text " ",' ',/ /...any special charter should print same text if input "hello" or hello should print hello or if input 'hello' should print hello... special charter should not display please me unable ...

i think need this:

string lwithoutspecials = first.replaceall("[^\\p{alpha}]+",""); 

for me works great:

string s = "\\hello\\ \"hello\" 'hello'"; string lwithoutspecials = s.replaceall("[^\\p{alpha}]+", ""); system.out.println(lwithoutspecials); 

output:

hellohellohello


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -