The moose likes Other Open Source Projects and the fly likes Servlet : upload and converter a ppt to pdf Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Reply Bookmark "Servlet : upload and converter a ppt to pdf" Watch "Servlet : upload and converter a ppt to pdf" New topic
Author

Servlet : upload and converter a ppt to pdf

amine berrabah
Greenhorn

Joined: Jan 18, 2012
Posts: 2
Hellow,
To upload and convert a ppt to pdf i use this servlet




i got this errors :

com.artofsolving.jodconverter.openoffice.connection.OpenOfficeException: connection failed: socket,host=localhost,port=8100,tcpNoDelay=1
com.artofsolving.jodconverter.openoffice.connection.AbstractOpenOfficeConnection.connect(AbstractOpenOfficeConnection.java:81)
servlet.ajout.doPost(ajout.java:170)
javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


i run the OOe on localhost and 8100,
i have add the jobconverter jars to the buikdpath
i dont know what is the matter !!!
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6371

What process runs and binds to port 8100 ? That seems to be missing. On a side note...

1. The servlet is a controller. It is doing more than what it should in your use case. A business object POJO is more suited to do the heavy lifting.
2. Class names must be in CamelCase.
3. A package named servlet does not sufficiently describe the intent of the classes under it.
4. Avoid using absolute paths / OS specific paths like (c:\)
5. After logging an exception with e.printStackTrace();, what does the user get to see on the browser ? Think about that.
6. I have many more but I am afraid they may side track your original question.


SCJP 6 articles - SCJP 5/6 mock exams - SCJP Mocks - SCJP 5 Mock exam (Word document ) - SCJP 5 Mock exam in Java.Inquisition format
amine berrabah
Greenhorn

Joined: Jan 18, 2012
Posts: 2
Deepak Bala wrote:What process runs and binds to port 8100 ? That seems to be missing. On a side note...

1. The servlet is a controller. It is doing more than what it should in your use case. A business object POJO is more suited to do the heavy lifting.
2. Class names must be in CamelCase.
3. A package named servlet does not sufficiently describe the intent of the classes under it.
4. Avoid using absolute paths / OS specific paths like (c:\)
5. After logging an exception with e.printStackTrace();, what does the user get to see on the browser ? Think about that.
6. I have many more but I am afraid they may side track your original question.


hi,
i have run the open office service on localhost and 8100 by this bat :

@echo off


rem Init start parameters
set OOO_APP="C:\Program Files (x86)\OpenOffice.org 3\program\soffice.exe"
set OOO_PARAM=-headless -norestore
set OOO_SOCKET="-accept=socket,host=localhost,port=8100,tcpNoDelay=1;urp;StarOffice.ServiceManager"- nofirststartwizard

rem Start OpenOffice.org
echo start "OpenOffice.org" %OOO_APP% %OOO_PARAM% %OOO_SOCKET% >>oo.log
start "OpenOffice.org" %OOO_APP% %OOO_PARAM% %OOO_SOCKET%

and i have used this class java to converte and it's work

package finale;

import java.io.File;
import java.net.ConnectException;

import com.artofsolving.jodconverter.DocumentConverter;
import com.artofsolving.jodconverter.openoffice.connection.*;
import com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter;

public class PptConvert{

public static void main(String[] args) {

String newname = "ra";


File inputFile = new File("C:\\file-ppt\\"+newname+".ppt");
System.out.println("Jointure de ppt en cours ...");

File outputFile = new File("C:\\file-essai\\"+newname+".pdf");
System.out.println("Creation de pdf en cours ...");

OpenOfficeConnection connection = new SocketOpenOfficeConnection(8100);
System.out.println("Connexion avec OOo (localhost:8100) en cours ...");

try {
connection.connect();
System.out.println("Connexion éffectuée ... ");
} catch (ConnectException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}


DocumentConverter converter = new OpenOfficeDocumentConverter(connection);
converter.convert(inputFile, outputFile);
System.out.println("Convertion en cours ...");


connection.disconnect();
System.out.println("Deconnexion en cours ...");
}
}

so i dont see the exactely the error for the connection !


Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6371

There is no valid explanation why the call would not work from a servlet. May be the open office server was simply down ?
 
jQuery in Action, 2nd edition
 
subject: Servlet : upload and converter a ppt to pdf
 
Threads others viewed
Servlet not dircting to the next page
renameTo()
Msg not received by SIP client
display the log/output in JSP or HTML page
JSP that converts office extensions to pdf and then upload them
developer file tools