Skip to content
Snippets Groups Projects
Commit 7c127ad6 authored by qalel's avatar qalel
Browse files

no message

parent 8781740f
Branches main
No related tags found
No related merge requests found
Pipeline #34068 failed
Showing
with 219 additions and 0 deletions
pom.xml 0 → 100644
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>nl.utwente.di</groupId>
<artifactId>bookQuote</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>11</release>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<filteringDeploymentDescriptors>true</filteringDeploymentDescriptors>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!-- Dependency added for Tomcat 8.5 (Servlet 3.1 API) -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.8.2</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
\ No newline at end of file
File added
File added
File added
File added
File added
File added
File added
package nl.utwente.di.bookQuote;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
/** Example of a Servlet that gets an ISBN number and returns the book price
*/
public class BookQuote extends HttpServlet {
/**
*
*/
private static final long serialVersionUID = 1L;
private Quoter quoter;
public void init() throws ServletException {
quoter = new Quoter();
}
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String docType =
"<!DOCTYPE HTML>\n";
String title = "Fahrenheit converter";
out.println(docType +
"<HTML>\n" +
"<HEAD><TITLE>" + title + "</TITLE>" +
"<LINK REL=STYLESHEET HREF=\"styles.css\">" +
"</HEAD>\n" +
"<BODY BGCOLOR=\"#FDF5E6\">\n" +
"<H1>" + title + "</H1>\n" +
" <P>Fahrenheit: " +
request.getParameter("isbn") + "\n" +
" <P>Celsius: " +
Double.toString(quoter.getBookPrice(request.getParameter("isbn"))) +
"</BODY></HTML>");
}
}
package nl.utwente.di.bookQuote;
import java.util.HashMap;
public class Quoter {
double getBookPrice(String isbn) {
double fahrenheit = Double.parseDouble(isbn);
return (Double) ((fahrenheit-32) * (5/9));
}
}
File added
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<display-name>di.bookQuote</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
<description>BookQuote Servlet</description>
<display-name>BookQuote</display-name>
<servlet-name>BookQuote</servlet-name>
<servlet-class>nl.utwente.di.bookQuote.BookQuote</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>BookQuote</servlet-name>
<url-pattern>/bookQuote</url-pattern>
</servlet-mapping>
</web-app>
\ No newline at end of file
<!DOCTYPE HTML>
<!-- Front end for the webBookQuote Servlet. -->
<html lang="en">
<head>
<title>Web Fahrenheit to Celsius transformer</title>
<link rel="stylesheet" href="styles.css">
<meta charset="UTF-8">
</head>
<body>
<h1>Web Fahrenheit Application</h1>
<form ACTION="./bookQuote">
<p>ENter the fahrenheit you want converted to celsius <input TYPE="TEXT" NAME="isbn"></p>
<input TYPE="SUBMIT">
</form>
</body>
</html>
BODY { background-color: WHITE }
H1 { color: PURPLE;
text-align: left;
font-size: 28px;
font-family: Arial, Helvetica, sans-serif;
font-weight: normal
}
.LARGER { font-size: 120% }
.TINY { font-size: 50% }
H2 { color: #440000;
text-align: left;
font-family: Arial, Helvetica, sans-serif
}
H3 { color: #440000;
text-align: left;
font-family: Arial, Helvetica, sans-serif
}
UL { margin-top: 0;
border-top-width: 0;
padding-top: 0
}
P { color: BLACK;
text-align: left;
font-size: 20px;
font-family: Arial, Helvetica, sans-serif
}
FORM { color: BLACK;
text-align: left;
font-size: 20px;
font-family: Arial, Helvetica, sans-serif
}
PRE { font-size: 105%;
}
CODE { font-size: 105%;
}
.TOC { font-size: 90%;
font-weight: bold;
font-family: Arial, Helvetica, sans-serif
}
TH.COLORED { background-color: #FFAD00
}
TR.COLORED { background-color: #FFAD00
}
TH.TITLE { background-color: #EF8429;
font-size: 40px;
font-family: Arial, Helvetica, sans-serif;
}
A:hover { color: red }
File added
File added
package nl.utwente.di.bookQuote;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
public class TestQuoter {
@Test
public void testBook1() throws Exception {
Quoter quoter = new Quoter();
double price = quoter.getBookPrice("1");
Assertions.assertEquals(10.0,price,0.0,"Price_of_book_1");
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment