By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,704 Members | 1,270 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,704 IT Pros & Developers. It's quick & easy.

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

P: n/a
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

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

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
The two essential things in the code below are:

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
and it can then be accessed from the JSP page with the method

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

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, {

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)
<%=MyModelObject.getSomeDataToBeShown()% >
Nov 17 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.