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") %>  <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!