Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > J2ME - use an external directory from a .jar

Reply
Thread Tools

J2ME - use an external directory from a .jar

 
 
nightm nightm is offline
Junior Member
Join Date: Jun 2008
Posts: 2
 
      06-26-2008
Hello,

I am working at a Web Server for Mobile Devices in J2ME. I made allready the base structure with sockets. My only problem for now remains the HTTPDOCS directory where I need to put the xhtml, css, imagines, servlets and over files which it can be acces from a browser on the Internet or localhost. I create a path to this directory in SRC (I use netbeans) and it works (with little problems but is a step foward). The problem is if I do this I need to include the HTTPDOCS directory into the .JAR and if I do that I can't change the files from the public directory unless I build the application again.
I presume that I need to work with an external directory or external resources but I don't have any ideea how to do that.

Please help me.
 
Reply With Quote
 
 
 
 
nightm nightm is offline
Junior Member
Join Date: Jun 2008
Posts: 2
 
      06-27-2008
I think JSR 75 File Connection API is what I need. I hope I can change and understand the dir's path, because in this moment I have something like this:

Code:
String request;

// Allows to access the webserver content like resources
Class resource = this.getClass();

......................................................
// READ THE BUFFER and if is not empty do this:

request = new String(buffer,0,length);

// Obtaing the resource path specified by the get request
String path = request.substring(4,request.indexOf("HTTP") - 1);

// if is a directory sends the index.html
if(path.endsWith("/"))
   path += "index.html";

// Adds the request path to the path specified
   path = "/httpdocs" + path;
                                        
// Open the request path with the help of resource as Stream
InputStream reader = resource.getResourceAsStream(path);

// If the reader is null, the request is not found, sends a error 
if(reader == null)
  // stop here because the httpdocs directory was't found :(
else
{
  // the httpdocs dir was found so read the buffer, etc. 
}

I think instead of that peace of code I need to do something like dir = (FileConnection)Connector.open("file://localhost/" + currDirName); but I don't understand where to get this file on localhost and how to get the resource as a stream for this path.

Someone have an ideea ?
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
System.IO.Directory.GetDirectories() and System.IO.Directory.GetFiles() are not returning the specified directory Nathan Sokalski ASP .Net 2 09-06-2007 03:58 PM
Will application J2ME MIDP 2.0 based of one device run another J2ME MIDP 2.0 device? nishadixit Java 5 06-01-2005 05:40 AM
J2ME/ktoolbar: Send an sms to an emulated J2ME-App Markus Java 4 02-12-2005 01:20 PM
J2ME Lime error 10061 (Re: Help with J2ME Wireless Toolkit) Boldra Java 0 12-03-2003 11:30 AM
Can i using j2me program to download and run other j2me programs in emulator? robin Java 0 07-20-2003 12:59 AM



Advertisments