Remove Space from URL
I Working on implementing search on my website. I am just passing in the search keyword to java. the url is being formatted and contructed in java. My stuff works fine if I pass in single word say "finance".
But if I have a space in my search keyword like "finance estimate" then its throwing error. I am sending the search keyword in a form/ GET method.
How should I take out the space and look like one word
This is the error
javax.servlet.ServletException
at com.ford.fc.atd.servlet.AbstractFrontController.doPost(AbstractFrontController.java:72)
at com.ford.fc.atd.servlet.AbstractFrontController.doGet(AbstractFrontController.java:40)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:226)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:124)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:283)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
at com.ford.fc.atd.servlet.filter.AbstractFilter.invokeNextFilter(AbstractFilter.java:65)
at com.ford.fc.atd.servlet.filter.AbstractFilter.doFilter(AbstractFilter.java:43)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
at com.ford.fc.atd.servlet.filter.XSSParameterEncodingFilter.doFilter(XSSParameterEncodingFilter.java:79)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3393)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(Unknown Source)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2140)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2046)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRe开发者_开发问答questImpl.java:1366)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:200)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:172)
You could replace spaces with %20, but that only helps with spaces and won't escape other characters. What you really need to do is use a URL-escaping function.
精彩评论