title: Applet in Spring MVC : ClassNotFound
body: <p>By running the applet from a jsp page the mapping gets changed down the line due to spring security.
  I have created Maven project using Spring MVC.
  Here is my Jsp page</p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1"
      pageEncoding="ISO-8859-1"%&gt;
  &lt;%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%&gt;
  &lt;HTML&gt;
  &lt;HEAD&gt;
  &lt;TITLE&gt;Java applet example - Passing applet parameters to Java applets&lt;/TITLE&gt;
  &lt;/HEAD&gt;
  &lt;BODY&gt;
  &lt;object type="application/x-java-applet" height="300" width="550"&gt;
      &lt;PARAM NAME="Downloadfile" VALUE="${Downloadfile}"&gt;
      &lt;PARAM NAME="Tempstorage" VALUE="${Tempstorage}"&gt;
         &lt;param name="archive" value="/webapps/pages/Applet.jar" /&gt;
        &lt;param name="code" value="MainApplet8" /&gt;
  &lt;/object&gt;
  &lt;/BODY&gt;
  &lt;/HTML&gt;
  </code></pre>
  
  <p>I have placed Applet.jar at : /src/webapps/pages/Applet.jar</p>
  
  <p>Here is my MainApplet.java code :</p>
  
  <pre><code>public class MainApplet8 extends Applet
  {
       public void init()
       {
           String SourceUrl;
           final String DestinationPath = getParameter("Tempstorage");
           SourceUrl = getParameter("Downloadfile");
           System.out.println(SourceUrl + "," + DestinationPath);         
            File myFile = (File) AccessController.doPrivileged(new PrivilegedAction() {
                public Object run()
                {
                    return new File(DestinationPath);
                }
                });
            if (SourceUrl != null &amp;&amp; DestinationPath != null) {
               try {               
                   URL url = new URL(SourceUrl);
                   URLConnection con = url.openConnection();
                   FileOutputStream ot = new FileOutputStream(myFile);
                   BufferedInputStream in = new BufferedInputStream(
                           con.getInputStream());
                   int n;
                   while ((n = in.read()) != -1) {
                       ot.write(n);
                   }
                   in.close();
                   ot.close();
               } catch (Exception e) {
                   JOptionPane.showMessageDialog(null,  "AA::::" + e.getMessage());
                   e.printStackTrace();
               }
               try {
                   System.out.println("Executing the application");                
                   Desktop.getDesktop().open(new File(DestinationPath));
                   int processExit = 0;             
               } catch (Exception e) {
                   JOptionPane.showMessageDialog(null,  "A::" + e.getMessage());
                   e.printStackTrace();
               }
           }
       }
  }
  </code></pre>
  
  <p>Error log in eclipse :</p>
  
  <p>WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/eSenseReengineering/tc-teacher/rs/MainApplet8] in DispatcherServlet with name 'appServlet'</p>
  
  <p>Note: I am redirecting Jsp page from following method : </p>
  
  <pre><code>@RequestMapping(value = "rs/openFile", method = RequestMethod.GET)
  public String openFile(@RequestParam(value = "path", required = true) String path, @RequestParam(value="objectName", required = true) String objectName,@RequestParam(value="objectType", required = true) String objectType, Model model, HttpServletRequest request) {
      String destinationPath = "D:/temp/"+objectName+"."+objectType;
      String hostURL = request.getRequestURL().toString();
      hostURL = hostURL.substring(0, hostURL.indexOf(Constants.contextName));
      String sourcePath = hostURL+ path;
      request.setAttribute("Downloadfile", sourcePath);
      request.setAttribute("Tempstorage",destinationPath);    
      return "test";
  }   
  </code></pre>