Ask a Question related to ASP.NET General, Design and Development.
-
NoSpamForMe@nospam.com #1
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
-
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... -
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... -
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... -
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... -
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... -
NoSpamForMe@nospam.com #2
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



Reply With Quote

