As you probably already know, L2jServer has changed its code update policy and now updates are released approximately once a month, but nevertheless, the code remains open and available to everyone who wants to learn and install Freya.
→
L2Teon has made almost 150 code adjustments since the release of the last revision of the Lineage 2 Interlude java server. Thanks to this, the security and fault tolerance of the server were increased. Updated item sharpening protection, fixed spawn list. Fixed a bug with pets. Disabled loading AI from the kernel, now only from “\data\scripts\ai\”. Fixed skills: Curse of Doom, Anchor, Mirage. Fixed a bug with the warehouse (the FloodProtector data was incorrectly specified). Fixed a bug with the pet disappearing after death. Spell Force and Battle Force skills have been fixed. The possibility of excessive sharpening of objects is closed. Correction of NPC table entries so that there are no errors in the console.
→
Java Development The Lineage 2 Gracia Epilogue server or simply Plus continues, and today the next update is available for owners of servers based on L2Open-Team. Added an option responsible for the chance of raising the level of Soul Crystal. Fixed the third floor in Steel Citadel, or rather the ability to go to it. Added mana recovery for Orc Shaman when hit. Fixed receiving magical support for beginners. Fixed character invisibility. Manor seeds from Lineage 2 Gracia Epilogue have been added. Added new quest Pailaka Injured Dragon (test required). The engine implements the "Seven Arrow" skill. Added Events: Last Hero and Base Capture. The administrator has access to a teleport to all Gracia Raid Bosses.
→
Once again, an update to the Lineage 2 Epilogue server build from the L2jServer team has been released with revision 4309 for the kernel and 7529 for the datapack. Fixed display of the action window when performing a transformation. Possibility to activate caching of all names of existing characters. Fixed an issue with auto-nipple being disabled on equipped weapons. Added setting for broadcasting range of events with ships. A new option is available to enable Champions to spawn on the map. Implementation of clan airships, correction of the flight path in quests. Added support for more precise search of double windows. A Geodvig error that resulted in the display of “Can”t see target” has been fixed. It is no longer possible to trade in vehicles. The droplist is checked when the server loads for “left” items.
Last update: 09/20/2018
The Java Bean class must meet a number of restrictions:
have a constructor that doesn't take any parameters
define getter and setter methods for all properties that are used in jsp
The names of getters and setters must follow the conventions: get (for a getter) and set (for a setter) are added before the variable name, and the variable name is capitalized. For example, if a variable is named firstName, then the getter and setter functions should be named getFirstName and setFirstName, respectively.
However, for boolean variables, the getter function uses the prefix is instead of get. For example, the enabled variable and the isEnabled getter.
implement the Serializable or Externalizable interface
Let's look at how to use JavaBean classes. Let's say we have the following structure:
In the Java Resources/src folder there is a User class with the following code:
Import java.io.Serializable; public class User implements Serializable ( private static final long serialVersionUID = 2041275512219239990L; private String name; private int age; public User() ( this.name = ""; this.age = 0; ) public User(String name, int age) ( this.name = name; this.age = age; ) public String getName() ( return name; ) public void setName(String name) ( this.name = name; ) public int getAge() ( return age; ) public void setAge(int age) ( this.age = age; ) )
This class represents the user and is a Java Bean class: it implements the Serializable interface, has a parameterless constructor, and its getter and setter methods that provide access to the name and age variables follow the conventions.
A user.jsp page is defined in the WebContent folder. Let's define the following code in it:
User Java Bean Page
Name: $(user.name)
Age: $(user.age)
This jsp page receives a user object from the outside and uses EL syntax to display the values of its properties. It is worth noting that here the variables name and age are referenced, although they are private.
In the Java Resources/src folder, the HelloServlet.java file defines the HelloServlet servlet:
Import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @WebServlet("/hello") public class HelloServlet extends HttpServlet ( protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException ( User tom = new User("Tom", 25); request.setAttribute("user", tom); getServletContext() .getRequestDispatcher("/user.jsp") .forward(request, response); ) )
The servlet creates a User object. To pass it to the user.jsp page, the "user" attribute is set via the call request.setAttribute("user", tom) . Next, there is a redirect to the user.jsp page. And thus the page will receive data from the servlet.
Is there a way to create a very simple HTTP server (supporting only GET/POST) in Java using only the Java SE API, without writing code to manually parse HTTP requests and manually format HTTP responses? The Java SE API nicely encapsulates HTTP client functionality in HttpURLConnection, but is there similar functionality for an HTTP server?
Just to be clear, the problem I have with a lot of the ServerSocket examples I've seen online is that they do their own request parsing/response algorithm and error handling, which is tedious, error-prone, and unlikely be all-encompassing, and I try to avoid it for these reasons.
As an example of manual HTTP manipulation that I'm trying to avoid:
18 answers
Starting with Java SE 6, the Sun Oracle JRE has a built-in HTTP server. The com.sun.net.httpserver package summary describes the participating classes and provides examples.
Here's a starting example, copied from their docs (however, anyone trying to edit it because it's a terrible piece of code, please don't copy, not mine, moreover, you should never edit quotes unless they've changed in the original source). You can just copy and run it on Java 6+.
package com.stackoverflow.q3732109; import java.io.IOException; import java.io.OutputStream; import java.net.InetSocketAddress; import com.sun.net.httpserver.HttpExchange; import com.sun.net.httpserver.HttpHandler; import com.sun.net.httpserver.HttpServer; public class Test ( public static void main(String args) throws Exception ( HttpServer server = HttpServer.create(new InetSocketAddress(8000), 0); server.createContext("/test", new MyHandler()); server.setExecutor( null); // creates a default executor server.start(); ) static class MyHandler implements HttpHandler ( @Override public void handle(HttpExchange t) throws IOException ( String response = "This is the response"; t.sendResponseHeaders(200, response.length()); OutputStream os = t.getResponseBody(); os.write(response.getBytes()); os.close(); ) ) )
It should be noted that the response.length() part of their example is bad, it should have been response.getBytes().length . Even in this case, the getBytes() method must explicitly specify the encoding, which you then specify in the response header. Alas, although misleading for beginners, it is, after all, just a basic example.
Execute it and go to http://localhost:8000/test and you will see the following response:
Regarding the use of com.sun.* , note that this, contrary to what some developers think, is absolutely not prohibited by the common FAQs. Why developers shouldn't write programs called "solar" packages. This sun.misc.BASE64Encoder FAQ is about the sun.* package (Such as sun.misc.BASE64Encoder) for internal using Oracle JRE (which will thus kill your application if you run it on another JRE), not the com.sun.* package. Sun/Oracle also just develops software on top of the Java SE API like any other company like Apache and so on. The use of com.sun.* is recommended (but not prohibited) when it comes to implementation specific Java API such as GlassFish (Java EE impl), Mojarra (JSF impl), Jersey (JAX-RS impl) etc.,
The com.sun.net.httpserver solution is not portable via the JRE. It's better to use the official web services API in javax.xml.ws to load a minimal HTTP server...
Import java.io._ import javax.xml.ws._ import javax.xml.ws.http._ import javax.xml.transform._ import javax.xml.transform.stream._ @WebServiceProvider @ServiceMode(value=Service .Mode.PAYLOAD) class P extends Provider ( def invoke(source: Source) = new StreamSource(new StringReader("
Hello There!
")); ) val address = "http://127.0.0.1:8080/" Endpoint.create(HTTPBinding.HTTP_BINDING, new P()).publish(address) println("Service running at "+address) println( "Type +[C] to quit!") Thread.sleep(Long.MaxValue)
EDIT: this actually works! The above code looks like Groovy or something like that. Here's the Java translation I tested:
Import java.io.*; import javax.xml.ws.*; import javax.xml.ws.http.*; import javax.xml.transform.*; import javax.xml.transform.stream.*; @WebServiceProvider @ServiceMode(value = Service.Mode.PAYLOAD) public class Server implements Provider