Page 1 of 2 12 LastLast
Results 1 to 10 of 18

Thread: Applet in Spring MVC

  1. #1

    Default Applet in Spring MVC

    Hi

    I'm going to use applets in my web application (Spring MVC + JSP), but I can't correctly map the request. Right now I'm facing problems with firefox to open <embed> tag, so I'm using <applet>, that works for me on both IE and FF.
    I get an exception compaining that I have no mapping in my DispatcherServlet for the applet. How am I supposed to do this mapping?

    This is a very simple question, but even googling I could not find out how to do it.

    Any tip/hint is welcome!
    Thanks!

  2. #2

    Default

    If that makes any difference here, I'll be using <applet> tag. I know it is deprecated, but it seems more compatible in some browsers (my FF3 still can't accept <embed> no matter what).

    Still, how can I map an applet in Spring MVC?
    Thanks!

  3. #3

    Question

    Did you ever find a solution to this?

    I can't figure it out.

    The DispatcherServlet wants a mapping to the *.class
    yet I have added the jar file to the root of the project thus leaving it
    outside of WEB-INF

    I add a jar package with many classes
    but java never picks up my class within the jar package.


    Code:
    <applet name="jumpLoaderApplet"
    		code="jmaster.jumploader.app.JumpLoaderApplet.class"
    		archive="jumploader_z.jar"
    		width="600"
    		height="400" 
    		mayscript>
    	<param name="uc_uploadUrl" value="/uploadHandler"/>
    </applet>

    Code:
    load: class jmaster.jumploader.app.JumpLoaderApplet.class not found.
    java.lang.ClassNotFoundException: jmaster.jumploader.app.JumpLoaderApplet.class
    
    Caused by: java.io.IOException: open HTTP connection failed:http://localhost:8080/webapp/jmaster/jumploader/app/JumpLoaderApplet/class.class

  4. #4
    Join Date
    Jul 2009
    Posts
    19

    Default

    where are you serving the jmaster.jumploader.app.JumpLoaderApplet.class from?
    within your WEB-INF? or some location similar to your javascript?

  5. #5

    Default

    Outside the WEB-INF folder. Accessible on the client side

    Code:
    webapp/
    .
    .jumploader_z.jar
    .
    .JavaScript/
    .
    .WEB-INF/
           .
           .
           .lib
           .view

    Its an open source Image Uploading Applet,
    So I tried following directions from its site

    http://jumploader.com/doc_overview.html
    check the applet configuration.

    Do i need to pack the jar file a different way?

  6. #6

    Default

    Try this-

    In your jsp file-
    <param name="uc_uploadUrl" value="uploadHandler"/>
    In your web.xml -
    <url-pattern>/uploadHandler</url-pattern>

  7. #7

    Default

    Nope it didn't work

    the param name="uc_uploader" is the url called to post the images.

    I just want to be able to run the applet on screen.

    I think there is a problem due to spring security.

    The mapping changes from "/jmaster/jumploader/app/JumpLoaderApplet.class"
    to "/jmaster/jumploader/app/JumpLoaderApplet/class.class"

    as it goes down the filter line.

    Code:
    31  WARN PageNotFound:959 - No mapping found for HTTP request with URI [/webapp/jmaster/jumploader/app/JumpLoaderApplet.class] in DispatcherServlet with name 'springmvc'
    15:42:49,632 DEBUG HttpSessionSecurityContextRepository:316 - SecurityContext contents are anonymous - context will not be stored in HttpSession. 
    15:42:49,632 DEBUG DispatcherServlet:643 - Successfully completed request
    15:42:49,633 DEBUG ExceptionTranslationFilter:100 - Chain processed normally
    15:42:49,633 DEBUG SecurityContextPersistenceFilter:87 - SecurityContextHolder now cleared, as request processing completed
    15:42:49,678 DEBUG FilterChainProxy:197 - Converted URL to lowercase, from: '/jmaster/jumploader/app/jumploaderapplet/class.class'; to: '/jmaster/jumploader/app/jumploaderapplet/class.class'
    15:42:49,678 DEBUG FilterChainProxy:204 - Candidate is: '/jmaster/jumploader/app/jumploaderapplet/class.class'; pattern is /**; matched=true
    I just can't get the applet's jar file to be picked up

  8. #8

    Default

    I have this and it works for me-

    Try this-

    ---------------------------------------------------------------
    under Web-

    put jumploader_z.jar & your jsp file with applet code
    Applet code =
    <applet name="jumpLoaderApplet"
    code="jmaster.jumploader.app.JumpLoaderApplet.clas s"
    archive="jumploader_z.jar"
    width="600"
    height="400"
    mayscript >
    <param name="uc_uploadUrl" value="uploadHandler"/>

    under lib -
    put your cos.jar file

    under web.xml-
    put this code-

    <servlet>
    <servlet-name>uploadHandler</servlet-name>
    <servlet-class>com.ejustice.servlets.uploadHandler</servlet-class>
    <load-on-startup>2</load-on-startup>
    </servlet>
    <servlet-mapping>
    <servlet-name>uploadHandler</servlet-name>
    <url-pattern>/uploadHandler</url-pattern>
    </servlet-mapping>

    under your uploadHandler.java file-
    put this code-


    import com.ejustice.rms.logger.ApplicationLogger;
    import com.ejustice.util.ApplicationResourceBundle;
    import java.io.*;
    import java.util.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;

    import com.oreilly.servlet.MultipartRequest;

    public class uploadHandler extends HttpServlet {

    @Override
    public void doPost(HttpServletRequest req, HttpServletResponse res)
    throws ServletException, IOException {
    res.setContentType("multipart/form-data");
    PrintWriter out = res.getWriter();

    try {
    System.out.println("Here in the class 1 of upload handler");
    String dir = (String) ApplicationResourceBundle.getResource("localDirPat h");
    System.out.println("----------- Image upload local machine dir is::------------" + dir);
    MultipartRequest multi =
    new MultipartRequest(req, dir, 50 *1024 * 1024,
    new com.oreilly.servlet.multipart.DefaultFileRenamePol icy());

    out.println("<HTML>");
    out.println("<HEAD><TITLE>Upload File</TITLE></HEAD>");
    out.println("<BODY>");
    out.println("<H1>UploadTest</H1>");

    // Print the parameters we received
    out.println("<H3>Params:</H3>");
    out.println("<PRE>");
    Enumeration params = multi.getParameterNames();
    while (params.hasMoreElements()) {
    String name = (String)params.nextElement();
    String value = multi.getParameter(name);
    out.println(name + " = " + value);
    }
    out.println("</PRE>");

    // Show which files we received
    out.println("<H3>Files:</H3>");
    out.println("<PRE>");
    Enumeration files = multi.getFileNames();
    while (files.hasMoreElements()) {
    String name = (String)files.nextElement();
    String filename = multi.getFilesystemName(name);
    String original = multi.getOriginalFileName(name);
    String type = multi.getContentType(name);
    File f = multi.getFile(name);
    out.println("name: " + name);
    out.println("filename: " + filename);
    if (filename != null && !filename.equals(original)) {
    out.println("original file name: " + original);
    }
    out.println("type: " + type);
    if (f != null) {
    out.println("length: " + f.length());
    }
    out.println();
    }
    out.println("</PRE>");
    }
    catch (Exception e) {
    out.println("<PRE>");
    e.printStackTrace(out);
    logger.error("Cause of error is:"+ e.getMessage());
    out.println("</PRE>");
    }
    out.println("</BODY></HTML>");

    }

    ---------------------------------------------------
    Let me know if this doesnt work

    Thanks
    Aashish

  9. #9

    Default

    I tried what you posted but no luck,

    I'm a little confused as to your mapping using the standard
    web.xml mapping, where I have to put both the front end DispatcherServlet(all requests should be going through this)
    and a custom uploadHandler mapping for the uploaded image class,

    I've never seen this in a Spring MVC app before

    Code:
    <servlet>
    		<servlet-name>springmvc</servlet-name>
    		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    		<load-on-startup>1</load-on-startup>
    	</servlet>
    	
    	<servlet-mapping>
    		<servlet-name>springmvc</servlet-name>
    		<url-pattern>/</url-pattern>
    	</servlet-mapping>
    	
    	<servlet>
    		<servlet-name>uploadHandler</servlet-name>
    		<servlet-class>com.myapp.images.UploadHandler</servlet-class>
    		<load-on-startup>2</load-on-startup>
    	</servlet>
    	
    	<servlet-mapping>
    		<servlet-name>uploadHandler</servlet-name>
    		<url-pattern>/uploadHandler</url-pattern>
    	</servlet-mapping>

    Are you using jumploader_z.jar in a Spring MVC application?

    And you said you place the jsp and jumploader_z.jar within the "Web-" ,does this mean WEB-INF folder?

    I tried it inside and outside the WEB-INF,

    nothing has changed and my spring filter chain mapping still somehow modifies the mapping... to .. "/class.class"


    The uploaderHandler.java should work when I'll be able to load the applet,
    So the only problem im facing is correctly mapping the jumploader_z.jar class through the DispatcherServlet.


    The full Java Console Stack

    Code:
    Exception: java.lang.ClassNotFoundException: jmaster.jumploader.app.JumpLoaderApplet.class
    load: class jmaster.jumploader.app.JumpLoaderApplet.class not found.
    java.lang.ClassNotFoundException: jmaster.jumploader.app.JumpLoaderApplet.class
    	at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
    	at java.lang.ClassLoader.loadClass(Unknown Source)
    	at java.lang.ClassLoader.loadClass(Unknown Source)
    	at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
    	at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
    	at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
    	at java.lang.Thread.run(Unknown Source)
    Caused by: java.io.IOException: open HTTP connection failed:http://localhost:8080/myapp/jmaster/jumploader/app/JumpLoaderApplet/class.class
    	at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unknown Source)
    	at sun.plugin2.applet.Applet2ClassLoader.access$000(Unknown Source)
    	at sun.plugin2.applet.Applet2ClassLoader$1.run(Unknown Source)
    	at java.security.AccessController.doPrivileged(Native Method)
    	... 7 more
    Exception: java.lang.ClassNotFoundException: jmaster.jumploader.app.JumpLoaderApplet.class
    Thanks for your time,
    Allan

  10. #10

    Default

    Hi Allan

    -----------------------------------------------------------------
    Basically your stack says that it is not finding the applet class which comes from jumploader_z.jar
    I believe that on your jsp page it is giving "Error:click for details" message.

    1. Where is your jumploader jar is placed?
    2. Can you post your jsp code here?

    Your questions were-
    3. Are you using jumploader_z.jar in a Spring MVC application?
    => Yes

    4. And you said you place the jsp and jumploader_z.jar within the "Web-"
    ,does this mean WEB-INF folder?
    => jumploader jar will never work inside of WEB-INF folder because it is a
    client side jar not the server side(atleast thats what I figured when I
    was coding)

    Post your jsp code & jumploader jar path here
    ---------------------------------------------------

    Thanks
    Aashish Dalmia

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •