This post is the Google App Engine using java servlet.
Java servlet is server side class.
If you using java servlet that possible to use html language in java.
First, make new project for google app engine.
Non check sample code!!
I make 3 java files.
Second, coding.
This is main.java
- @SuppressWarnings("serial")
- public class main extends HttpServlet{
- @Override
- protected void doGet(HttpServletRequest req, HttpServletResponse resp)
- throws ServletException, IOException {
- // TODO Auto-generated method stub
- //super.doGet(req, resp);
- resp.setContentType("text/html; charset=UTF-8");
- PrintWriter show=resp.getWriter();
- show.println("메인 페이지 입니다. </BR>");
- show.println("당신의 IP는 "+req.getRemoteAddr()+" 입니다. </BR>");
- show.println("1번으로 가실려면 <a href=/num1>이곳</a>을 눌러주세요.</BR>");
- show.println("2번으로 가실려면 <a href=/num2>이곳</a>을 눌러주세요.</BR>");
- }
- }
Line 9 : for Korean(UTF-8)
Line 10~17 : print to web browser. possible to using html.
Third, Mapping.
This is web.xml
- <servlet>
- <servlet-name>main</servlet-name>
- <servlet-class>com.answerofgod.test.main</servlet-class>
- </servlet>
- <servlet-mapping>
- <servlet-name>main</servlet-name>
- <url-pattern>/</url-pattern>
- </servlet-mapping>
Line 1~5 : servlet define.
Line 6~9 : servlet mapping.
Forth, Deploy to App Engine.
Connect to webpage.
MAIN |
NUM1 |
NUM2 |
No comments:
Post a Comment