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.h ttp.HttpServlet Request.setAttr ibute
and it can then be accessed from the JSP page with the method
javax.servlet.h ttp.HttpServlet Request.getAttr ibute
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.R equestDispatche r.forward
Here is the code that I would like to see translated into .NET/C# :
import javax.servlet.h ttp.HttpServlet Request;
import javax.servlet.h ttp.HttpServlet Response;
import javax.servlet.h ttp.HttpServlet ;
public class MyController extends HttpServlet {
protected void doPost(HttpServ letRequest req, HttpServletResp onse
resp) throws javax.servlet.S ervletException , java.io.IOExcep tion {
MyModelClass MyModelObject = new MyModelClass();
req.setAttribut e("MyModelKey ", MyModelObject);
req.getRequestD ispatcher("/jspView.jsp").f orward(req, resp);
}
}
Some code that then could be used inside the webpage "jspView.js p" :
MyModelClass MyModelObject = (MyModelClass)
req.getAttribut e("MyModelKey") ;
<%=MyModelOb ject.getSomeDat aToBeShown()% > 0 2417 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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.
|
by: Ashutosh |
last post by:
How can i convert Word file to txt file in ASP.NET using CSharp?
|
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 hard drive.
In my VB6 past I've almost exclusively used MDB files for this purpose but
I'm thinking that XML would be a simpler, better solution for this
application. So I tried using "XMLSerialization" but it failed. I'm not
really sure why...
|
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 comprised of a DataGrid may have separate permissions for adding, deleting and updating a news item.
Problem
Up until now, I have been implementing security directly inside the control. I will test directly against the security model to see if...
|
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. The conversion need to be done
in coding as a web service using ASP/ASP.Net
2) How to import pulic classes into an ASP file (in java we use, import)
Thanks
| |
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 instead of 06.
Thanks a lot.
|
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 outside of that
class. This structured way allows visual tools to host components, and
allows programmers to build applications and libraries visually in a RAD
environment.
The Java language has JavaBeans as its component model which allows Java...
|
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 the 2.0 files changed IIS to use
Framework 2.0 and changed the application pool, also restarted IIS. When I
try to get to the web service it tells me the file cannot be found. The web
service file(asmx) is in the same place and named the same. The...
|
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, with push down stack algorithm to DB2 query. The client does not want
to use Stored Procedure.
Please any Recurcive or CWE ideas.
Thank's in advance.
-- Tree holds the adjacency model
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |