http-request-parameters

HTTPServletRequest getParameterMap() vs getParameterNames

天大地大妈咪最大 提交于 2019-12-05 14:40:44
问题 HTTPServletRequest req, has a method getParameterMap() but, the values return a String[] instead of String , for post data as name=Marry&lastName=John&Age=20. I see in the post data it's not an array, but getParameterMap() returns array for every key(name or lastName or Age). Any pointers on understanding this in a better way? The code is available in Approach 2. Approach 1 works completely fine. Approach 1: Enumeration<String> parameterNames = req.getParameterNames(); while (parameterNames

how can i use request parameter in struts2 if tag

a 夏天 提交于 2019-12-04 17:43:33
i have a link like this : http://localhost:8080/ESA/login.jsp?login=failed in end of above link a set a parameter with name login and value failed . how i can use this parameter in jsp page with struts if tag. I use following code but it don't work. <s:if test="%{#parameters.login='failed'}"> <div class="error"> <s:text name="user.login.failed"></s:text> </div> </s:if> Try with <s:if test="%{#parameters.login[0]=='failed'}"> The two problems were in your code: The = sign is an assignment, not equals == ; Parameters are saved in the Map<String, String[]> , so each parameter could have multiple

How to get a form parameter in servlet? request.getAttribute does not work

有些话、适合烂在心里 提交于 2019-12-04 14:00:05
问题 Is it possible to have the same servlet perform validation? It seems that one might have to utilize some sort of recursion here, but when I type in something in the e-mail box and click submit the e-mail parameter is still blank. After I click submit, the URL changes to: http://localhost/servlet/EmailServlet?Email=test The page shows Email: null and the text box, but I was expecting it to go through the validation function (i.e. not be null). Is it possible to achieve this type of recursive

Restoring request parameters in @ViewScoped bean after session expires

夙愿已清 提交于 2019-12-04 11:56:24
I have a page that has the setup as below with url like my.page.com/table.xhtml?id=123 : +----------------------------------------------+ |Meta information | |----------------------------------------------| | Search Fields Submit btn | |----------------------------------------------| | | | | | Big p:dataTable | | with rowExpansion | | | |----------------------------------------------| | Pager | +----------------------------------------------+ id=123 is the request parameter that controls the content on the result table. All actions only reload the data table using AJAX . id is loaded throught

Preserving the selected value in an HTML select element after refreshing a JSP page

不想你离开。 提交于 2019-12-04 04:59:31
问题 I have a JSP with drop down box. I select one option and submit that one. So now I get the information stored in the database of that selected option. Now I refresh the JSP (HTML page) automatically by setting in servlet as //servlet code inside doGet() method HttpSession session=request.getSession(); String selUrl=request.getParameter("urlsel"); String opt=session.setAttribute("selectedUrl",selUrl); String selopt=session.getAttribute("selectedUrl"); response.setHeader("Refresh","10;url="

MultipartFile returns null every time

旧巷老猫 提交于 2019-12-03 21:27:59
I am using this code to post an image file to my controller but I always get a null value for the file body part. @RequestMapping(value = "/updateprofile", method = RequestMethod.POST) public @ResponseBody ResponseMsg updateProfile( @RequestHeader(value = "userid", required = false) String userid, @RequestHeader(value = "name", required = false) String name, @RequestHeader(value = "phone", required = false) int phone, @RequestParam(value = "file", required = false) MultipartFile file) { ResponseMsg responseMsg = CommonUtils.checkParam(userid, name, phone, file); if (responseMsg.getStatus()

How to get a form parameter in servlet? request.getAttribute does not work

烈酒焚心 提交于 2019-12-03 08:50:53
Is it possible to have the same servlet perform validation? It seems that one might have to utilize some sort of recursion here, but when I type in something in the e-mail box and click submit the e-mail parameter is still blank. After I click submit, the URL changes to: http://localhost/servlet/EmailServlet?Email=test The page shows Email: null and the text box, but I was expecting it to go through the validation function (i.e. not be null). Is it possible to achieve this type of recursive behavior? public class EmailServlet extends HttpServlet { public void doGet(HttpServletRequest request,

How to access url parameters in struts2

心不动则不痛 提交于 2019-12-03 08:48:34
I am working on a struts2 project. I have created url with in my project and have passed parameters using tags. My question is how do i read the parameter in the actions? also if do the same would i be able to see the parameters as query string. i ask because i am not able to and i saw it in one of the tutorials. Typically, you will interact with parameters in your actions by using fields on your actions, exposed by setters. Assume the following URL maps to my example Struts2 action: URL http://localhost/myAction?firstName=SonOfTheEARTh Action Code public class MyAction extends ActionSupport {

Preserving the selected value in an HTML select element after refreshing a JSP page

大憨熊 提交于 2019-12-02 06:15:54
I have a JSP with drop down box. I select one option and submit that one. So now I get the information stored in the database of that selected option. Now I refresh the JSP (HTML page) automatically by setting in servlet as //servlet code inside doGet() method HttpSession session=request.getSession(); String selUrl=request.getParameter("urlsel"); String opt=session.setAttribute("selectedUrl",selUrl); String selopt=session.getAttribute("selectedUrl"); response.setHeader("Refresh","10;url="/SiteAvailabilityServlet?ursel="+selectedUrl); //and forwarding request to result.jsp using

@ManagedProperty with request parameter not set in a @Named bean

﹥>﹥吖頭↗ 提交于 2019-11-30 20:41:47
I've a CDI managed bean wherein I'd like to set request parameters as managed properties: import javax.inject.Named; import javax.enterprise.context.RequestScoped; @Named @RequestScoped public class ActivationBean implements Serializable { @ManagedProperty(value="#{param.key}") private String key; @ManagedProperty(value="#{param.id}") private Long id; // Getters+setters The URL is domain/activate.jsf?key=98664defdb2a4f46a527043c451c3fcd&id=5 , however the properties are never set and remain null . How is this caused and how can I solve it? I am aware that I can manually grab them from