J2me with servlet
hello experts
Sir i want to call a servlet program in a j2me program i have found a program related to my requirment on
net. But there is a problem that when i run as it is program according to net i give url="http://www.mycgiserver.com/servlet/corej2me.WebsiteDemo_CallServletGET"on my toolkit it is runing correct,
but when i give url according to my system for servlet like "http://localhost:8000/servlets/CallServletGET"
when i click submit button for calling to servlet
then its it is giving error that "Unable to read data" . my coding is like this
if (http.getResponseCode() == HttpConnection.HTTP_OK)
iStrm = http.openInputStream();
// 2) Get header information - none
// 3) Get body (data)
int length = (int) http.getLength();
if (length > 0)
byte servletData[] = new byte[length];
iStrm.read(servletData);
// Update the string item on the display
fmMain.append("You passed to the servlet: \n" + new String(servletData));
else
fmMain.append("Unable to read data");
When you post code, please use[code] and [/code] tags as described in Formatting Help on the message entry page. It makes it much easier to read.
Please post the full error. If this is running on an emulator, please post the stack trace ( throwable.printStackTrace() ).
Which phone is it running on? (Suns WTK, Nokia, etc?)
Is the Servlet being called (as some debug lines into the servlet ([url http://java.sun.com/j2se/1.5.0/docs/api/java/util/logging/package-frame.html]java.util.logging ). )
Similar Messages
-
I would like to know, who knows, how i can make a connection J2ME with NMEA protocol(GPS), somebody can give me a source code example? Thanks !!
You can find a very nice tutorial on http://servlet.java.sun.com/javaone/sf2002/conf/sessions/18-introductory-expanded.en.jsp
You should have found this if you had googled "j2me nmea", it was on the third place ;)
And now that you know this, can you write a GPS-spy program for me, because I'm a total newbe in this kind of stuff. (just kidding :) -
Communicate with servlet after using Java Web Start?
Is it possible to communicate with servlet to get data back and forth
after using Web Start to download the client application?
The demos come with Java Web Start are applications which are
standalone, don't need communicate with the servlet on Web server
after being launched. I am wondering if it is possible, and how (HTTP
& JAX-RPC)?
Thanx in advance.I've done this using HTTP. I get the server and port from the codebase:
BasicService bs = null;
try {
bs = (BasicService)ServiceManager.lookup("javax.jnlp.BasicService");
String codeBase = bs.getCodeBase().toString();
and use the java.net.HttpURLConnection and java.net.URL classes to send HTTP parameter values to the servlet and to receive results from the HttpURLConnection's input stream. -
Displaying *.pdf file on browser with servlet
hi all
this RAMESH,struggling to display a pdf file on browser from a remote mechine
earlier i tried with servlet
response.setContentenType("application/pdf")
out.println();
by this i am getting only some data as below
endobj
4 0 obj
<<
/ProcSet [ /PDF /Text /ImageB ]
/Font << /Fo0 21 0 R /Fo12 24 0 R /Fo13 27 0 R /Fo16 30 0 R /Fo18 33 0 R /Fo19 36 0 R >>
>>
endobj
For this purpose i have gone thru www.lowagie.com
and gone thru all examples but i am not getting how to display on browser or at least awt frame
please requesting all for suggest me some way
tanks all
-Rameshare you trying to
a) create a PDF dynamically
b) send an existing PDF -
Hi
i was trying to do some example with JNI. I can use JNI with standalone Java application but I just cannot figure out how I can use JNI with Servlet.
Can some one show me a sample code using JNI with Servlets.
thanks very muchhi,
I am also facing the same problem,
when I am using JNI with stand alone application it works fine but when i tried to use it with a servlet It gives unsatisfied linker error
stack: java.lang.UnsatisfiedLinkError: createSocket
at RelayConnector.createSocket(Native Method)
at RelayServlet.doGet(RelayServlet.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.iplanet.server.http.servlet.NSServletRunner.invokeServletService(NSServletRunner.java:891)
at com.iplanet.server.http.servlet.NSServletRunner.Service(NSServletRunner.java:458)
It seems i have to do some path settings in my iplenet web server.
If some one have faced the problem i would be glad to know the solution for this, i am literally bugged up,.... -
Hi,
I am Tejas , a newbie with servlets. Now, I have a servlet which contains a Javascript method. On clicking a link , the Javascript method is called.
But however, I find that there is some trouble. I created a class called MainFrames.java, the object of which I am instantiating in the Javascript method.
But this code doesnt work properly. I have given the snippet below
out.println("<script type='text/javascript'>");
out.println("function threader()");
out.println("{");
out.println("alert('Inside Threader');");
out.println("<%@ page import=\"XcForm.MainFrames\"%>"); //I have a hunch that this statement is the problem
out.println("<%");
out.println("MainFrames mainframes = new MainFrames();"); //without the import statement above, the MainFrames.java class is not being recognised
out.println("%>");
out.println("}");
out.println("</script>");
Thanks in advance,
TejasDo not put presentation code in servlets. Put them in JSPs. And mixing serverside code (scriptlets) and clientside code (javascript) this way is indeed not going to work. That code will certainly not be executed in the order as you write. Serverside code is executed at the server and is finished when the response is completed. So any serverside code inside clientside code is alreay executed. Clientside code is executed at the client and will only execute when the response is completed (onload, etc) or when the client invokes it (onclick, onsubmit, etc). Further on, do not put business code in presentation code. Put them in servlets.
-
JSF 1.2 with SERVLET 2.3
Hi, i've download the latest JSF 1.2 RI but i can't see any page as i get the following error:
ava.lang.NoSuchMethodError: javax.servlet.http.HttpServletResponse.getContentType()Ljava/lang/String;
at com.sun.faces.context.ExternalContextImpl.getResponseContentType(ExternalContextImpl.java:277)
at com.sun.faces.renderkit.RenderKitImpl.createResponseWriter(RenderKitImpl.java:167)
at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:131)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:222)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
The getContentType method that the exception describes is only available in servlet 2.4 but i'm using a servlet 2.3 only container. Can i use JSF 1.2 with servlet 2.3 ?
ThanksI'm 90% sure that you cannot. JSF 1.2 is intended to be part of Java EE 5.0. Since Servlets 2.3 are part of J2EE 1.3, I don't think that it will work.
Adam -
Some problems with servlet.jar and tomcat 4.1.27
Hello everybody,
I used to work with tomcat 3.3.1 and i've decided to use tomcat 4.1.27 now. The manual explains that we have to change de version of servlet.jar, it's done with servlet-2.3.jar but on tomcat starting i have this message:
jar not loaded. See servlet spec [...]. Offending class: javax/servlet/Servlet.class
what can i do, i've red all de documentation and i think all versions a OK??
thanks per advance
antoineI am running Tomcat 4.1.18, so your configuration may be slightly different. I found the Servlet.class file you are missing residing in the Tomcat/common/lib directory in the Servlet.jar file. Check your path and also make sure your Servlet.jar file contains the missing class.
-
Communicating with Servlets....
hi!
Wat are all the different ways in which the JSP used to communicate with Servlet?
Thanx,
Rgds,
SasiJsp page communication with Servlets....
web.xml -- Servlets loaded during application startup
struts config -- Servlet mapping (w.r.t struts).
and u can import servlets in jsp and can use it... there are so many possible ways of using servlets coz jsp pages inturn convert into servlets and got executed..... -
Im using tomcat 4.06 and i have some problems with servlets and forwarding:
This is my servlet:
import java.io.PrintWriter;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletContext;
public class NTenant extends HttpServlet {
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
String email = request.getParameter("tenant");
//insert new tenant into database.
System.out.println("Redirigiendo");
ServletContext sc = getServletConfig().getServletContext();
RequestDispatcher rdNext = sc.getRequestDispatcher("/tenantForm.html");
rdNext.forward(request, response);
System.out.println("Redirigido");
I get this error:
type Status report
message Servlet invoker is currently unavailable
description The requested service (Servlet invoker is currently unavailable) is not currently available.
This is my dir structure:
webapps\form\NewTenant.html
webapps\form\tenantForm.html
webapps\form\WEB-INF\web.xml
webapps\form\WEB-INF\classes\NTenant.class
webapps\form\WEB-INF\classes\TenantServlet.class
The problem is that i cannot find my html, what must i write here? sc.getRequestDispatcher("/tenantForm.html"); <-----
Thank you very muchI heve tried with "../tenantForm.html"
java.lang.IllegalArgumentException: Path ../tenantForm.html does not start with a "/" character
at org.apache.catalina.core.ApplicationContext.getRequestDispatcher(ApplicationContext.java:572)
at org.apache.catalina.core.ApplicationContextFacade.getRequestDispatcher(ApplicationContextFacade.java:174)
at NTenant.doPost(NTenant.java:19)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
Now Im trying with:
RequestDispatcher rdNext = sc.getRequestDispatcher "/../tenantForm.html");
And I got:
type Exception report
message Internal Server Error
description The server encountered an internal error (Internal Server Error) that prevented it from fulfilling this request.
exception
java.lang.NullPointerException
at NTenant.doPost(NTenant.java:20)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:465)
at org.apache.catalina.servlets.InvokerServlet.doPost(InvokerServlet.java:216)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2347)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1027)
at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1125)
at java.lang.Thread.run(Thread.java:536)
Any other idea? -
Hi
Does anyone know how to use dialogs with servlets? I'd like to show a confirm dialog on the client machine. My first idea was to use JOptionPane.showConfirmDialog as such in the servlet, but then of course de dialog pops-up on the server side, and not on client side.
Many thanks for the help,
NicYou need to use javascript to confirm, ask questions, etc...
You can see :
http://www.webreference.com/programming/javascript/confirm/
Or
http://www.bodo.com/javacool.htm
Fred -
Hi,
how we can use swings with servlets or jsps.
or
how we can display the browser in the swings.
please give me a valid answer with examples.Hi,
Your question is not clear... are you trying to display HTML using swing components or are you trying to use swing in a server-side application?
Some Swing components (e.g. JLabel) natively support simple html, so:
JLabel lbl = new JLabel("<html>hello <b>world</b></html>");would result in a JLabel that looks with the word "world" in bold. If you need also frames, css and javascript support - you'll need to reach for a 3^rd^ party library, I'm afraid.
As for using swing in servers, look at this article:
http://today.java.net/pub/a/today/2006/04/20/bringing-swing-to-the-web.html
If you meant neither, please explain more.
Hope this helps, though.
Michael Bar-Sinai -
[Help] To prevent timeout error of browser in clinet with servlet in server
Hi all,
If a browser (for example, Internet Explorer) do not get any response from a server for more than sometime (in case of IE, default is 5 min), it will stop waiting and return some timeout error message.
But I have a servlet, which has a really long-time(at least 10 min) job to do before it could send a response to the browser. So, before the browser in client can get the result, it stops waiting.
I know I can change the time-out setting of browser in client machines, but there are hundred of thousands.
So, what I am asking is if it is possible to do it with servlet in server, and how?
(for example, send something to the client every few minutes, but I do not know how to do it .)
thanks a lot!What you would have to do is set up some sort of 'Buffer' servlet.
It starts the job in the background, and then returns a page saying job started - client does not time out.
You would have to start it in a seperate process - probably a new Thread.
The client would then have to send back requests asking - is it finished yet?
While the job is not finished the buffer servlet returns a "not yet" message.
On completion, the job can be sent back to the client.
Couple of pointers:
It may be easier to have the background process generate the result to file - then your buffer servlet can just pick up the file when it is completed.
To get your page to refresh multiple times, you can use javascript: window.setTimeout("[reload page]");
Good luck,
evnafets -
I have a project with servlets in the 2 following folders
myprojects and myclasses
In my projects I have the helloProject and inside it I have the helloHtml folder and the helloPackage.
So in the helloHtml folder I have the hello.html file and in the helloPackage I have the Hello.java (which is the servlet)
when I compile this .java file the class file is inserted in the file myclasses\helloProject\helloPackage
First in the file hello.html I have the code
action="http://localhost:8080/servlet/helloPackage.Hello
and so the servlet is executed fine.
The problem is that I need to put a button in the code of Hello.java
so that I can have reloaded the first page which is the hello.html
But I am confused if I write onclick=history.go(-1) I have what I want but this page is not reloaded so I have some parameters there that I do not want
Can I write sth like onclick=location.href=http://locahost:8080/.....??
Could you please give me an advice considering the above description of my files??
Thank tou very much....use sendRedircet(String AbsoluteURL) to send the Browser a redirect header so the browser send a new (fresh) request to the serlvet (with any parameter you specified).
-
Hi,
I am facing a problem with servlet which compresses the MS Excel files in gzip format,
when i try opening the Template.gz file using winzip or gzip.exe,it throws me an error as either " invalid zip file" or " archive directory not valid"
Can someone pls help in resolving this porblem,
Its very very urgent for me to solve this problem,
My servlet code snippest is as below,
I am using Microsoft Internet Explorer 6.0 to download template.gz file which supports gzip and deflate formats,
--------TemplateGenerator.java-----------------
public void doPost(HttpServletRequest req, HttpServletResponse res)
String encodings = req.getHeader("Accept-Encoding");
System.out.println(encodings);
res.setHeader("Content-Encoding", "gzip");
res.setHeader("Content-Disposition", "attachment;filename=Templates.gz");
try{
//First create User directory
String dir = "C:/";
String separator = System.getProperty("file.separator");
//Read the files in the current directory and write to zip file
GZIPOutputStream zip = new GZIPOutputStream(res.getOutputStream());
File dir1 = new File(dir);
File[] list = dir1.listFiles();
if(list == null)
System.out.println("No files");
else
for(int k=0;k < list.length; k++)
int filelen = (int)list[k].length();
System.out.println("File Length :"+filelen);
FileInputStream fis = new FileInputStream (list[k]);
byte[] tempfile = new byte[filelen];
int bytesRead = fis.read( tempfile,0,filelen );
// checking bytesRead not shown.
fis.close();
// write the contents into the zip element
zip.write( tempfile , 0, filelen );
zip.finish();
// close the entire zip
zip.flush();
zip.close();
-------------------------------------------------Hi !
I am using following code to do that in my project, It might help you..
String message = "your String" ;
ByteArrayInputStream bais = new ByteArrayInputStream(message.getBytes());
InputStreamReader isr = new InputStreamReader(bais);
XmlPullParser pp = new KXmlParser();
pp.setInput(isr);-Jestan
Maybe you are looking for
-
ITunes Fails To Download iOS For iPod Touch In Recovery
I have an iPod Touch 5 (without camera) that was messed with by someone and ended up disabled for 45 years. As waiting 45 years until I can put in the pass code is not practical, *snickers* I put the iPod into Recovery Mode and went to restore it on
-
Problem with a flash banner in a php includes
I am creating a site that has many pages and I made an includes file for the header of the page that contains my navigation bar, i then made a template of the page to use for all my pages. Now I have created a flash banner that i want to play in the
-
I ugraded my i5 to iOS7. It does not let me charge my phone with the given cable even though its the original cable that I got with the phone.
-
New curve 8310, thought I would say hello
Hello everyone. I just got my first BB the other day and as a matter of fact my first real phone in like 4 years. So its all quite overwhelming even for a technical guy like myself. Im in Canada and chose Rogers but the phone itself is not Rogers.
-
Photoshop CS6 crashing on MAC. You don't have permission to use "AdobeCrashDaemon"
We are having issue with users unable to open Photoshop on MAC machines at school network. 34 machines that are in the Media Device Group on the profile manager. If remove them from the device group the applications work. Product: Adobe CS6 Master Co