aspose file tools*
The moose likes Java Micro Edition and the fly likes GET and POST in J2ME using JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "GET and POST in J2ME using JSP" Watch "GET and POST in J2ME using JSP" New topic
Author

GET and POST in J2ME using JSP

Intan Syafiqah
Greenhorn

Joined: May 05, 2012
Posts: 11
Hello....

i'm new beginner for J2ME...so i would like to ask whether we can use JSP to GET and POST in J2ME...
I have try some coding but it not working...
i also try to get data from sql using jsp through J2Me but is have some error..
s0 it is possible we can use jsp to get and post in j2me..
or maybe you can give me some simple example GET and POST in J2ME using JSP.....

i really appreciate your help....

Thank you...
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
I may be misunderstanding what you're trying to do, but you can't use a JSP "in JME" (it hasn't been J2ME for years). JSPs are a server-side web technology, and you wouldn't run a servlet container in a JME environment.

What is perfectly possible is that a JME app would send an HTTP request to a servlet container which is handled by a JSP. Generally, you wouldn't address the JSP directly, though, but go through a servlet or some other kind of "handler" or "action" component, which then in turn uses a JSP.

The fact that you got "some error" doesn't mean that it isn't possibly - it simply means that you have a bug in there somewhere. If you told us what error that is, specifically, and what you're trying to do, exactly, we might be able to help.
Intan Syafiqah
Greenhorn

Joined: May 05, 2012
Posts: 11
thanks for your answer..there is my coding..
i'm try to request my username and password using JSP handler...
but when i try to pass airtime in midlet i can't....
i hope you can solve my problem.....

here is LoginTest.java (midlet)



here is my jsp coding (indexDB.jsp)
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
Intan Syafiqah wrote:but when i try to pass airtime in midlet i can't....

Why not? What, exactly, are you trying to do, and what, exactly, is the result? There seems to be code that makes an HTTP call, but it's not clear whether that code is being called, or if there are any exceptions if it is in fact called. Those are the details we'd need to know in order to help you.

It's also not clear whether the JSP is ever accessed, or -if it is- what the result of that is. Note that the practice of embedding Java code in JSPs has been considered bad practice for a decade. That's no way to implement a mobile solution. You should think about this in terms of REST, with no JSP being involved at all.
Intan Syafiqah
Greenhorn

Joined: May 05, 2012
Posts: 11
Thanks for your information...

What I'm try to do is i try to log in to database through JSP handler..
and I'm try to get the username and password at J2ME and compare it in database mySQL through JSP handler..
it is my J2ME coding is wrong or my JSP handler coding wrong??

if you have any example to log in J2ME interface through JSP handler with mySQL database..
please let me know..i really need your help...
and i really appreciate it..
Thank you..
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
What I meant is: What happens if you run this code? Is the HTTP call actually being made? Note that I'm not asking if you think it should be made - I'm asking if you have verified in some way that it is actually being made.

Assuming that it is made, what is the result on the server side? Which parts of the JSP or are not being executed? How does that differ from what you thought would happen?

Also note that the DB code in the JSP is wide open to SQL injection attacks; you need to fix that before using this in a production setting. At the least, use a PreparedStatement.
Intan Syafiqah
Greenhorn

Joined: May 05, 2012
Posts: 11
Here is the error went i try to pass airtime...

Warning: To avoid potential deadlock, operations that may block, such as
networking, should be performed in a different thread than the
commandAction() handler.

i don't know what the error..
It is there have some error on my method commandAction handler....
i really confuse on that method...

please help me....
i really appreciate your help...
Thank you...
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4642
    
    5

First off, that's a warning, not an error.

Go through these two pages: Networking, User Experience, and Threads and Using Threads in J2ME Applications


luck, db
There are no new questions, but there may be new answers.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: GET and POST in J2ME using JSP