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>