fragsurpatte | Bonjour, je travaille actuellement à la fois sur une applet et une servlet. Voilà la méthode de mon applet qui utilise la servlet
Code :
- class exec implements ActionListener
- {
- public void actionPerformed(ActionEvent e) {
- try {
- URL url = new URL("http://localhost:8080/AppletServlet2/ServletMessage" );
- URLConnection connexion = url.openConnection();
- connexion.setDoOutput(true);
- connexion.setRequestProperty("Content-Type", "application/octet-stream" );
- ObjectOutputStream sortie = new ObjectOutputStream(connexion.getOutputStream());
- sortie.writeObject(t5.getText());
- ObjectInputStream entree = new ObjectInputStream(connexion.getInputStream());
- JFrame resultat = new JFrame();
- resultat = (JFrame)entree.readObject();
- resultat.setVisible(true);
- JOptionPane.showMessageDialog(p1,"ca fonctionne","Information",JOptionPane.INFORMATION_MESSAGE);
- }
- catch (IOException erreur) {
- erreur.printStackTrace();
- JOptionPane.showMessageDialog(p1,"Problème pour lancer le traitement","Erreur",JOptionPane.ERROR_MESSAGE);
- }
- catch (ClassNotFoundException erreur) {
- erreur.printStackTrace();
- JOptionPane.showMessageDialog(p1,"...","Erreur",JOptionPane.ERROR_MESSAGE);
- }
- }
|
Voilà le code de ma servlet
Code :
- public class ServletMessage extends HttpServlet
- {
- public ServletMessage()
- {
- }
- public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
- {
- try{
- String f1 = "C:\\Program Files\\Apache Software Foundation\\Tomcat 5.0\\webapps\\AppletServlet2\\imtrac.xml";
- String f2 = "C:\\Program Files\\Apache Software Foundation\\Tomcat 5.0\\webapps\\AppletServlet2\\figaro.xml";
- ObjectInputStream in = new ObjectInputStream(request.getInputStream());
- String test = (String)in.readObject();
- ProcessingManager.EMULATED_MODE=true;
- ScenarioConstruction scr=new ScenarioConstruction(f1,f2);
- URL baseURL = (new File(f1)).toURL();
- URL stylesheetURL = (new File(f2)).toURL();
- XMIllumFrame frm = new XMIllumFrame(baseURL, stylesheetURL);
- scr.initBridge(frm);
- try{
- XMLDecoder pref = new XMLDecoder(new FileInputStream(System.getProperty("user.home" )+File.separator+"nadas.xml" ));
- Object rect = pref.readObject();
- pref.close();
- scr.setBounds((Rectangle)rect);
- }
- catch(Exception exc) {
- scr.setSize(new java.awt.Dimension(400, 650));
- scr.setLocation(new java.awt.Point(30,30));
- exc.printStackTrace();
- }
- scr.show();
- ObjectOutputStream out = new ObjectOutputStream(response.getOutputStream());
- //out.writeObject(frm.w);
- out.writeObject(test);
- }
- catch(Exception e){e.printStackTrace();}
- }
- }
|
Et voilà l'erreur d'exécution que j'ai :
Code :
- java.io.IOException: Server returned HTTP response code: 500 for URL: http://localhost:8080/AppletServlet2/ServletMessage
- at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:791)
- at projet_applet.Applet_Test$exec.actionPerformed(Applet_Test.java:328)
- at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1786)
- at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1839)
- at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
- at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
- at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:245)
- .........
|
Est ce que quelqu'un peut m'aider ?
|