Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

J2ME and JSP

 
Vince Hon
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Question about MIDlet and JSP.
I has written a simple jsp file that:
> Receieve the login name and password from user.
> Then, display the login name and password to users.
I use tomcat 4.1 and the jsp file works if I use IE. But how do I get the "password" and "login name" generated by the jsp file and display on the mobile phone ?
<I can connect to the web browser via the use of HttpConnection in MIDlet, but don't know how to "get" the items generated by the jsp file >
Thanks
 
Greg Schwartz
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vince,
After your JSP file does whatever processing it needs to do, you need to output the the information that you would like to send back to the mobile phone. You "output" the information (username / password) as if it were going to appear on a web page. This can just be plain text or can be more involved.
After you open your HttpConnection to the JSP page you're going to want to open and InputStream and call the read() function for that InputStream. The data that is returned by the read function is the data that was the output of your JSP page (username /password).
Hope that helps...
 
Vince Hon
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, I solved the problem, thank you very much.
By the way, I try to use servlet rather than JSP.
It seems servlet is more convenient, right ?
 
Michael Yuan
author
Ranch Hand
Posts: 1427
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Vince Hon:
Yes, I solved the problem, thank you very much.
By the way, I try to use servlet rather than JSP.
It seems servlet is more convenient, right ?

In fact, I would like to say that JSP is more convenient (no need to compile, packaging and deploy -- just copy the file). But servlet is a better solution (more capable and can adopt to different patterns) unless you server returns some sort of XML document.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic