How to convert a JSP model 2 application to ASP.NET and C#

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default Re: How to convert a JSP model 2 application to ASP.NET and C#

    I am currently a java programmer, with some knowledge of the C#
    language but very little knowledge about ASP.NET, and I am know
    wondering if someone can *translate* the java servlet code below to
    ASP.NET/C# ?

    Please note that I am not asking about the best possible way of doing
    the same thing with ASP.NET architecture with those "code behind"
    things I have heard a little about... but what I am asking for is a
    *translation* (other interface/class names and method names...)
    because I want to figure out if it is possible to convert an exisiting
    JSP model 2 application with a quite small effort (search and replace)
    without having to rewrite the entire application with a new
    architecture.

    And yes, I do have read a little about the "Java Language Conversion
    Assistant", but as Micrsoft says it can create support classes and
    "Support classes are sometimes substantially different architecturally
    from the classes they emulate".
    Maybe this conversion assistant also will generate a bunch of code
    behind classes, but I do not want to generate code that I don't really
    understand and will have a hard time to maintain, and that's why I
    want something that is VERY similar to JSP model 2.

    For those of you who now is wondering then why I don't keep the
    application in java instead of bothering about converting it, it is
    because I want to change webhost and the best webhosts I have found
    don't support java, but only ASP.NET.
    (for those of you that now would have a suggestion of a good java
    webhost then I am only interested in webhosts with servers in sweden,
    and the host will have to offer lots of bandwith for the price, and
    all the best ones from this point of view do unfortunately not offer
    java)


    The two essential things in the code below are:

    1)
    How to (from the controller) make model objects accessible from the
    web page. In a java servlet this is done (see below) with the method
    javax.servlet.http.HttpServletRequest.setAttribute
    and it can then be accessed from the JSP page with the method
    javax.servlet.http.HttpServletRequest.getAttribute

    2)
    How to (from the controller) choose web page to be shown for the user
    In a java servlet this is done (see below) with the method
    javax.servlet.RequestDispatcher.forward

    Here is the code that I would like to see translated into .NET/C# :

    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.http.HttpServlet;
    public class MyController extends HttpServlet {
    protected void doPost(HttpServletRequest req, HttpServletResponse
    resp) throws javax.servlet.ServletException, java.io.IOException {

    MyModelClass MyModelObject = new MyModelClass();
    req.setAttribute("MyModelKey", MyModelObject);
    req.getRequestDispatcher("/jspView.jsp").forward(req, resp);
    }
    }

    Some code that then could be used inside the webpage "jspView.jsp" :

    MyModelClass MyModelObject = (MyModelClass)
    req.getAttribute("MyModelKey");
    <%=MyModelObject.getSomeDataToBeShown()% >
    NoSpamForMe@nospam.com Guest

  2. Similar Questions and Discussions

    1. Create pdf from external application usingpdf-template and u3d model
      Hello, I want to develop an application (e.g. batch program), that create a pdf file with embedded 3d model using a pdf document on the file...
    2. How to pass model values to application file?
      I have an application file restaurant.mxml which makes a call to the CFC file as a webservice. I have created a mxml component (myReview.mxml ) to...
    3. Convert Struts application to Flex
      Hello, I am implementing an application with Struts, handling MVC, nevertheless want to modify the Vista of the client, a JSP, to change by a file...
    4. convert multiple docs to pdf with powerbuilder application
      From a powerbuilder application we print 5 different documents; 3 of these documents are Word and 2 are from a powerbuilder datawindow. Our aim is to...
    5. What issue will HIT me hard when I convert an Access 2002 MDE application to Web Application?
      Hi All, Current Access 2002 MDE application: - has no tier - has neither business object nor any kind of object (Except MS Form object and...
  3. #2

    Default How to convert a JSP model 2 application to ASP.NET and C#

    I am currently a java programmer, with some knowledge of the C#
    language but very little knowledge about ASP.NET, and I am know
    wondering if someone can *translate* the java servlet code below to
    ASP.NET/C# ?

    Please note that I am not asking about the best possible way of doing
    the same thing with ASP.NET architecture with those "code behind"
    things I have heard a little about... but what I am asking for is a
    *translation* (other interface/class names and method names...)
    because I want to figure out if it is possible to convert an exisiting
    JSP model 2 application with a quite small effort (search and replace)
    without having to rewrite the entire application with a new
    architecture.

    And yes, I do have read a little about the "Java Language Conversion
    Assistant", but as Micrsoft says it can create support classes and
    "Support classes are sometimes substantially different architecturally
    from the classes they emulate".
    Maybe this conversion assistant also will generate a bunch of code
    behind classes, but I do not want to generate code that I don't really
    understand and will have a hard time to maintain, and that's why I
    want something that is VERY similar to JSP model 2.

    For those of you who now is wondering then why I don't keep the
    application in java instead of bothering about converting it, it is
    because I want to change webhost and the best webhosts I have found
    don't support java, but only ASP.NET.
    (for those of you that now would have a suggestion of a good java
    webhost then I am only interested in webhosts with servers in sweden,
    and the host will have to offer lots of bandwith for the price, and
    all the best ones from this point of view do unfortunately not offer
    java)


    The two essential things in the code below are:

    1)
    How to (from the controller) make model objects accessible from the
    web page. In a java servlet this is done (see below) with the method
    javax.servlet.http.HttpServletRequest.setAttribute
    and it can then be accessed from the JSP page with the method
    javax.servlet.http.HttpServletRequest.getAttribute

    2)
    How to (from the controller) choose web page to be shown for the user
    In a java servlet this is done (see below) with the method
    javax.servlet.RequestDispatcher.forward

    Here is the code that I would like to see translated into .NET/C# :

    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.http.HttpServlet;
    public class MyController extends HttpServlet {
    protected void doPost(HttpServletRequest req, HttpServletResponse
    resp) throws javax.servlet.ServletException, java.io.IOException {

    MyModelClass MyModelObject = new MyModelClass();
    req.setAttribute("MyModelKey", MyModelObject);
    req.getRequestDispatcher("/jspView.jsp").forward(req, resp);
    }
    }

    Some code that then could be used inside the webpage "jspView.jsp" :

    MyModelClass MyModelObject = (MyModelClass)
    req.getAttribute("MyModelKey");
    <%=MyModelObject.getSomeDataToBeShown()% >
    NoSpamForMe@nospam.com Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139