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 6700789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:51:24+00:00 2026-05-26T06:51:24+00:00

I am developing for google app engine with JSP. And I need to compare

  • 0

I am developing for google app engine with JSP. And I need to compare two strings by startsWith() method in String class.

Here is the code I am working on.

    <% 
            String artist = "Surendra Perera";

            DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
            Key songKey = KeyFactory.createKey("songs", 123454);
            // Run an ancestor query to ensure we see the most up-to-date
            // view of the songs.
            Query query = new Query("Song", songKey).addSort("Artist");
            //query.addFilter("Artist", Query.FilterOperator.IN, "Milton Mallawarachchi");
            List<Entity> songsList = datastore.prepare(query).asList(FetchOptions.Builder.withLimit(30));
            if(songsList.isEmpty()){
            %>
            <p>There are no songs</p>
            <%
            }else{
%>
<ul class="playlist">
<%
            for(Entity song : songsList){
                if(artist.startsWith(song.getProperty("Artist"))){
%>

 <li><a href="<%= song.getProperty("Link") %>"><%= song.getProperty("Title") %>&#160;&#160;<span class="comment"><%= song.getProperty("Artist") %></span></a></li>

<% }}} %>   

And here is the error i am getting….

HTTP ERROR 500

Problem accessing /search.jsp. Reason: 
    Unable to compile class for JSP: 

An error occurred at line: -1 in the generated java file
    [javac] C:\DOCUME~1\SILICO~1\LOCALS~1\Temp\Jetty_127_0_0_1_8888_war____.g0qk00\jsp\org\apache\jsp\search_jsp.java:178: cannot find symbol
    [javac] symbol  : method startsWith(java.lang.Object)
    [javac] location: class java.lang.String
    [javac]                 if(artist.startsWith(song.getProperty("Artist"))){
    [javac]                          ^
    [javac] 1 error



Stacktrace:

Caused by:
org.apache.jasper.JasperException: Unable to compile class for JSP: 

An error occurred at line: -1 in the generated java file
    [javac] C:\DOCUME~1\SILICO~1\LOCALS~1\Temp\Jetty_127_0_0_1_8888_war____.g0qk00\jsp\org\apache\jsp\search_jsp.java:178: cannot find symbol
    [javac] symbol  : method startsWith(java.lang.Object)
    [javac] location: class java.lang.String
    [javac]                 if(artist.startsWith(song.getProperty("Artist"))){
    [javac]                          ^
    [javac] 1 error

Thanks in advance!

  • 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-05-26T06:51:25+00:00Added an answer on May 26, 2026 at 6:51 am

    The error is telling that it cannot find the given method method startsWith(java.lang.Object) in the String class. Please note that the error says java.lang.Object as method argument. This is indeed wrong. It has to be java.lang.String, see also the javadoc.

    You have to change the return type of song.getProperty() from Object to String:

    public String getProperty(String name) {
        // ...
    }
    

    Or to add a cast on (String) if it is actually of String type:

    if (artist.startsWith((String) song.getProperty("Artist"))) {
        // ...
    }
    

    Or to use a fullworthy Javabean:

    public String getArtist() {
        return artist;
    }
    

    with

    if (artist.startsWith(song.getArtist())) {
        // ...
    }
    

    Last but not least, this problem is unrelated to JSP. You would have exactly the same problem when doing so in a normal Java class. Writing Java code in a JSP file is not the best way to get the basic concepts right.

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

Sidebar

Related Questions

I'm developing a simple servlet/JSP, data-driven web site on Google App Engine. I've started
While developing a Google App Engine app, how can client code (i.e., javascript) detect
I'm developing a project on google app engine (webapp framework). I need you people
I am developing an Twitter4J web application in Google App Engine/Java. I need to
I'm developing software on google app engine. I'm using the webapp framework. is there
I'm considering developing an app for Google App Engine, which should not get too
I've been developing a Facebook app using Google App Engine in Python and the
I'm developing software using the Google App Engine. I have some considerations about the
I am developing a website using Google App Engine and Django 1.0 (app-engine-patch) A
I'm developing in Google App Engine (python sdk) and I want to use jQuery

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.