473,321 Members | 1,916 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,321 software developers and data experts.

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()% >
Nov 17 '05 #1
0 2375

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: mave | last post by:
Is anyone aware of a Java program preferably w/ source code to convert files in text format to xml format? Pls. let me know if you are aware of such a program.
1
by: Ashutosh | last post by:
How can i convert Word file to txt file in ASP.NET using CSharp?
1
by: Robert W. | last post by:
I'm building my first major C# WinForms application. I've successfully completed the forms and the data model and they work great. Now I'm moving on to saving/opening the data model to/from the...
1
by: Earl Teigrob | last post by:
Background: When I create a ASP.NET control (User or custom), it often requires security to be set for certain functionality with the control. For example, a news release user control that is...
3
by: Kishore | last post by:
1) Is there a way to convert a file (MPP format) into an XML document in ASP. Is there any relation with XMLSerializer class with this. Can we use this class to convert a file into an XML Document....
15
by: angellian | last post by:
Sorry to raise a stupid question but I tried many methods which did work. how can I conserve the initial zero when I try to convert STR(06) into string in SQL statment? It always gives me 6...
122
by: Edward Diener No Spam | last post by:
The definition of a component model I use below is a class which allows properties, methods, and events in a structured way which can be recognized, usually through some form of introspection...
7
by: Rick | last post by:
I have a web service that I converted from VS 2003 Framework 1.1. to VS 2005 Framework 2.0. I tried to use the same IIS web site to run the web service. I deleted the Framework 1.1 files published...
11
by: lenygold via DBMonster.com | last post by:
I am tryieng to convert our time consuming recursive queries too very efficient queries based on nested set model. The only problem is to convert an adjacency list model into a nested set model,...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.