~ changed helloWorld to find absolute path to config files
Signed-off-by: Johannes Theiner <j.theiner@live.de>
This commit is contained in:
parent
49287ee2e4
commit
4b6510d230
|
@ -15,20 +15,23 @@ import java.io.FileReader;
|
|||
* @since 0.1
|
||||
*/
|
||||
|
||||
@Getter
|
||||
@ToString
|
||||
@EqualsAndHashCode
|
||||
public class Configuration {
|
||||
|
||||
private static final String filename = "config.json";
|
||||
|
||||
@Getter
|
||||
private Database database;
|
||||
|
||||
|
||||
public static Configuration get(String fileName) {
|
||||
|
||||
public static Configuration get() {
|
||||
Gson gson = new Gson();
|
||||
|
||||
FileReader reader = null;
|
||||
try {
|
||||
reader = new FileReader(new File(fileName));
|
||||
reader = new FileReader(new File(filename));
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ public class Database {
|
|||
|
||||
@Nullable
|
||||
private Connection getConnection() {
|
||||
Configuration config = Configuration.get("config.json");
|
||||
Configuration config = Configuration.get();
|
||||
try {
|
||||
return DriverManager.getConnection("jdbc:mariadb://" + config.getDatabase().getHostname() + ":" + config.getDatabase().getPort() + "/" + config.getDatabase().getDatabase(), config.getDatabase().getUsername(), config.getDatabase().getPassword());
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ package de.hsel.itech.servlet;
|
|||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
|
@ -30,12 +31,15 @@ public class HelloWorld extends HttpServlet {
|
|||
|
||||
resp.setContentType("text/html");
|
||||
final PrintWriter out = resp.getWriter();
|
||||
out.println("<!DOCTYPE html>");
|
||||
out.println("<html>");
|
||||
out.println("<head>");
|
||||
out.println("<title>Hallo Welt!</title>");
|
||||
out.println("</head>");
|
||||
out.println("<body>");
|
||||
out.println("<h1>Hallo Ostfriesland!</h1>");
|
||||
out.println("<h1>Hallo Ostfriesland!</h1><br>");
|
||||
out.println("<h3>" + System.getProperty("catalina.base") + "</h3><br>");
|
||||
out.println("<h4>" + new File("").getAbsolutePath() + "</h4>");
|
||||
out.println("</body>");
|
||||
out.println("</html>");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue