request parameters from jsp in java without using servlets

夙愿已清 提交于 2020-01-06 04:50:11

问题


I want to request parameters in a java file from a jsp without using servlets. Does anyone know how to do this? I believe its something to do with setting an attribute but I'm new to java so its all a learning game from me. I want to send the lotsize and bedrooms parameters to the java file. My jsp file is shown below and i need to know what to put in my java file in order to retrieve these parameters


回答1:


Create a JSP file as shown below. Also Create a java file com.test.Room and pass the value to the Class

<%@ page import = "com.test.Room"%>

<html>
<body>

<%
   String bedRooms = request.getParameter("bedrooms");
   String lotSize = request.getParameter("lotSize");
%>
<ul>
    <li><p><b>bedrooms</b>
       <%=bedRooms%>
    </p></li>
    <li><p><b>lotsize</b>
       <%=lotSize%>
    </p></li>
 </ul>
<%
   Room room = new Room(bedRooms, lotSize);
   //Other logic, if any
%>
 <body>
 <html>


来源:https://stackoverflow.com/questions/54111199/request-parameters-from-jsp-in-java-without-using-servlets

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!