• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to extract Strings in J2ME?

 
Sachin Dere
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,
im reading data from Http which contains break.when i display it on the phone, it shows <BR>.how do i get rid of this <BR> we have replaceAll in String API but unfortunately, its not available in J2ME.
guys please help me.
Sachin
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well usually, when calling a Servlet, the Servlet should not return HTML, becuase then that would be a Servlet meant for a web page.

Usually, I make a Servlet that a J2ME app will call just to return plain text in the String and no HTML.

If you have to use the same Servlet for a Web and a J2ME application, then I suggest adding a parameter to the URL that states that it is coming from the J2ME device and therefore skip over the code that adds the HTML tags.

Personally, I think there is a much better design for this issue that addinga parameter. I think there should be two Servlets, one for the J2ME device and one for the Web Application, and any business logic should be pulled out into Plain Old Java Objects that both Servlets can share and use.

Mark
 
Sachin Dere
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mark,
thanks for ur reply. i agree with u .Well,i wrote a small method which strips out the unwanted tag which works well
thanks dude
Sachin
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic