question

JumboDumbo-8428 avatar image
1 Vote"
JumboDumbo-8428 asked Bruce-SqlWork answered

How do I implement JSP in C#

So I am trying to convert my Java JSP programm to an C# programm. I want to create a client.
I have my Index.jsp:

<%@ page import="model.Employee" %>
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html>
<head>
<title>Employee</title>
</head>
<body>
<h1><%= "Employee!" %>
</h1>
<br/>
<form action=hello-servlet method="post">
<p>Name
<input type="text" name="name">
</p>
<input type="submit" >
</form>
</body>
</html>

and an Employee.jsp file:

<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<jsp:useBean id="selectedEmployee" type="model.Employee" scope="request"></jsp:useBean>
<!DOCTYPE html>
<html>
<head>
<title>Employee</title>
</head>
<body>
${selectedEmployee.firstName}
<p>${selectedEmployee.lastName}</p>
</body>
</html>

Can someone help me create a client for my h2 database?

dotnet-csharp
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@JumboDumbo-8428, Welcome to Microsoft Q&A, which web app you want to converted from jsp to c#, is asp.net app or asp.net core app? Based on my research, we could not convert the jsp to c# directly, as usual, we convert jsp to js and html, then we used c# code to control it. Do you also want to do it like the above?

0 Votes 0 ·
BenDover-7389 avatar image
0 Votes"
BenDover-7389 answered

When you press on Wildyfly and Edit Configurations, do you have the right URL and are the right deployments there?

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Bruce-SqlWork avatar image
0 Votes"
Bruce-SqlWork answered

While classic asp.net uses the same template syntax (<% … %>), I’d still suggest use .net 6 razor pages. This is like a more modern approach, but architecturally similar modern jsp.

Beside converting the Java code to C# you will need to find replacements for your javabeans. There is no direct equivalent, you will probably create custom classes and pick nuget packages and use dynamic injection instead. Asp.net core and razor pages DI support has similar scoping to javabeans.

You should try some razor page tutorials. Pay attention to dynamic injection, and model binding.

You will also want to pick a replacement for h2. SQLite is a good choice, it’s more robust, faster and better supported. If you have existing data, you will find tools to do the convert.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.