Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7872919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:21:36+00:00 2026-06-03T02:21:36+00:00

I am using Java Servlet. In there, i have to use regular expression to

  • 0

I am using Java Servlet. In there, i have to use regular expression to filter out the text.
However, the java compiler says at the import of import java.util.regex.Pattern; “can not resolve the symbol”

Thus all my consecutive matcher and pattern functions are not working.

Can not we use regex packages in a servlet? i was not able to use contians function of string as it gave me an error too. Is there any alternative for the same ?

import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringReader;
import java.util.List;
import java.util.regex.Pattern;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.PostMethod;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.input.SAXBuilder;


public class HelloWorldExample extends HttpServlet {
public void doGet(HttpServletRequest request,HttpServletResponse response)throws IOException, ServletException
{
response.setContentType("text/plain;charset=ISO-8859-1");
PrintWriter out = response.getWriter();
String keyword = request.getParameter("inputValue");
HttpClient cl = new HttpClient();
String temp = "http://localhost:8080/solr/select/?q=*%3A*&version=2.2&start=0&rows=2000&indent=on";
PostMethod pst = new PostMethod(temp);

String XMLstr="<GIS>";
Perl5Util perl=new Perl5Util();

 try{
    cl.executeMethod(pst);
    String xmlstr=pst.getResponseBodyAsString();
    SAXBuilder sax=new SAXBuilder();
    Document doc= (Document) sax.build(new StringReader(xmlstr));
    Element rootElem=doc.getRootElement();
    Element res=rootElem.getChild("result");
    List docs=res.getChildren("doc");
    for(int i=0;i<docs.size();i++)
    {
        out.println("docsSize = " + docs.size());
        Element row= (Element)docs.get(i);
        List strs=row.getChildren("str");
        out.println("strs = " + strs.size());
        out.println("Hello");
        Element strRow=(Element)strs.get(0);
        String strContent=strRow.getText().toString();
        Element strRow1=(Element)strs.get(1);
        String Lati=strRow.getText().toString();
        Element strRow2=(Element)strs.get(2);
        String Longi=strRow.getText().toString();
        Element strRow3=(Element)strs.get(3);
        String FileName=strRow.getText().toString();
        if(strContent.contains(keyword))
        {
                //out.println("XMLstr: ");
                XMLstr+="<File><id>"+FileName+"</id><Lat>"+Longi+"</Lat><Long>"+F+"</Long>";
                //out.println("XMLstr: "+XMLstr);
            }   
        //out.println(strRow.getText());
        break;
    }
}catch(Exception e)
{
    out.println(e);
}   
}
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T02:21:37+00:00Added an answer on June 3, 2026 at 2:21 am

    As per the JavaDoc, the package should be java.util.regex.Pattern and not java.utils.regex.Pattern.

    EDIT: are you sure you have the appropriate syntax? (<%@ page import java.util.regex.Pattern %>). Maybe you are using an older version of Java? The Pattern class was made available in Java 1.5.

    To see what version you are currently running, open command prompt or terminal and type in java -version. This should yield the Java version you have running on your machine.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have web application written in java using Eclipse. It has just one servlet
I'm using Tomcat 6.0.33 with Java 6. I have this servlet ... public class
I have an application using Java servlets/JSP's. There are multiple clients using my app,
I'm sending some HTML code back to an iframe using a java servlet and
I'm building a simple java Servlet which passes categories using a URL variable into
I have to pass some strings from a java servlet to a php script.
We're creating a web system using Java and Servlet technology (actually Wicket for the
I recently started using Eclipse at work for my Java servlet projects. I've been
Is there a way to use a Seam Logger inside of a standard Java
Not a very common implementation, but using Processing as a Java Servlet has been

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.