Request.getParameter(
I have two combo boxes. whenever a user selects some value in first combo box then using ajax code i am getting the contents of other combo box. The first combobox is department list combo box and second one is employee list combo box. The contents of employee combobox (2nd combobox) can be populated in two different cases :-
1) Whenever user selects a department, using ajax i get the list of the employees of that department and display it in second combo box using javascript.
2) Whenever the user submits the form, the action is given to same page. So now when the same page is loaded i have the department and employee numbers which were selected in previous page. So using jsp code i retrieve the employee list from the database for the selected department and populate the combobox. and i make the employee who was selected in the previous page as selected in this page also.
Now My Problem is
When user selects a department then through ajax, code of employee combobox will be sent to server. When user selects a employee
from this combobox and submits the form then parameter value of department is not null but the parameter value of employee number is null. So in the submitted page i know the department he selected but i will not know what is employee he selected because request.getParmeter("employeeNumber") is returning null as stated above. Remember all the problem of employee combobox returning null as explained is occuring for the combobox which was generated by ajax code.
So what i am doing is that in the submitted page as i know the department id he selected, i am just getting the list of all employees
of that department using jsp code and displayed them on users combo box with no employee selected. So here the combobox is being generated by jsp code. Now here if i select the employee from the employee combobox which was generated by jsp code, and submit the form, Its working perfectly fine.
So the employee combobox which was generated by jsp code is working but the one which was generated by ajax code is not working.
and All this problems are only in firefox. In interenet explorer everything is fine in both cases.
I checked the codes generated by both methods. But they are exaclty same. What could be the problem??
I have two combo boxes. whenever a user selects some value in first combo box then using ajax code i am getting the contents of other combo box. The first combobox is department list combo box and second one is employee list combo box. The contents of employee combobox (2nd combobox) can be populated in two different cases :-
1) Whenever user selects a department, using ajax i get the list of the employees of that department and display it in second combo box using javascript.
2) Whenever the user submits the form, the action is given to same page. So now when the same page is loaded i have the department and employee numbers which were selected in previous page. So using jsp code i retrieve the employee list from the database for the selected department and populate the combobox. and i make the employee who was selected in the previous page as selected in this page also.
Now My Problem is
When user selects a department then through ajax, code of employee combobox will be sent to server. When user selects a employee
from this combobox and submits the form then parameter value of department is not null but the parameter value of employee number is null. So in the submitted page i know the department he selected but i will not know what is employee he selected because request.getParmeter("employeeNumber") is returning null as stated above. Remember all the problem of employee combobox returning null as explained is occuring for the combobox which was generated by ajax code.
So what i am doing is that in the submitted page as i know the department id he selected, i am just getting the list of all employees
of that department using jsp code and displayed them on users combo box with no employee selected. So here the combobox is being generated by jsp code. Now here if i select the employee from the employee combobox which was generated by jsp code, and submit the form, Its working perfectly fine.
So the employee combobox which was generated by jsp code is working but the one which was generated by ajax code is not working.
and All this problems are only in firefox. In interenet explorer everything is fine in both cases.
I checked the codes generated by both methods. But they are exaclty same. What could be the problem??
Similar Messages
-
Retriving only hidden parameters from request.getParameter
Hi,
I want to retrive only the hidden parameters from previous JSP page into current JSP page. The problem here is that my hidden parameters in privious page are dynamically generated (parameter names are decided based on values retrived from the database) and I cannot retrive them using "request.getParameter(<parametername>)"
Can I find the parameter type (i.e. text box, text area, checkbox, radio or hidden) from the request.getParameter() or request.getParameterNames() methods? or is there any other way to find it.
Thanks in advance for any helpYou can use the getParameterNames() or getParameterMap() methods from javax.servlet.ServletRequest to get all the parameters in the request. Even if they're dynamically generated, and you don't know the names in advance, these methods will ferret them out.
getParameterMap() returns name String, values String [] pairs, so you'll have to work with String arrays to get the input out. It's got to be that way to accomodate checkboxes and other HTML form elements that can send more than one value for a given name.
I prefer getParameterMap, because I don't like using Enumerations as much. - MOD -
Not able to get the full value from request.getParameter()
hi all,
Iam giving a text input value as" Analysis and tracking" in one jsp form.
while fetching and assigning the value to another variable using request.getparameter , iam getting only the text "Analysis" , the space after it were ignored andnt displaying it.
Help me in solving this.
thanx
BalajiI think you are code is something like this
<input name="xyz" type="text" value=<%=variable%>>
HTML ignores spaces. Therefore you are only getting Analysis, the first word, when your browser encounters the first space it ignores whatever is present after that.
One way of overcoming this is putting double quotes around the text value
<input name="xyz" type="text" value=<% out.println("\"" + variable + "\""); %>
Thanks. -
How to get Int value from request.getParameter()?
Hi all,
I have a integer value which is passed from one page to another page.
i am geting this value in the next page using
request.getParameter().
Eg.
Suppose value of "i" in page1 is 32, i pass this as hidden variable to next page.
<input type="hidden" Value="<%=i%>" NAME="limit">
in page2, i fethch this value to a variable by name "limit"
String limit=request.getParameter("limit");
but, since value stored in limit is int, i can't assign it to string.
i can't use request.getParameter for int values.
How to solve my problem.
I know it is simple,
Pls. help me
Regards
ASh
String limit=request.getParameter("limit");String limitSTR = request.getParameter("limit");
int limit = -1;
if (limitSTR != null) limit = Integer.parseInt(limitSTR); -
Null value in Session vars and request.getParameter
We're migrating our application from iPlanet.
Under iPlanet, when we looped through a resultset and set the values to
session variables - it worked fine, even when a resultset value was null,
but in WebLogic, I get the following error:
java.lang.IllegalArgumentException: key/value is null
Is there anyway to "turn this off" so it behaves like iPlanet?
My second question is that we have many JSP's that check to see if a
parameter is null in javascript:
Here's the code:
function onLoad() {
document.form.elements[0].focus();
// Check to see if the user is coming from a shortcut
var imageName = "<%=request.getParameter("imageName")%>";
if (imageName == "null") {
selectTop("<%=select_image%>");
} else {
selectTop(imageName);
<% if (tableIndex == 2) { %>
loadShortcutIcon(13,100);
<% } %>
in iPlanet, when the parameter "imageName" is not in the URL, the javascript
variable gets set to "null" - but in WebLogic, it is set to a blank string -
"". Is there anyway to make this return null like iPlanet?
Thanks,
Matt
Hi,
the URL parameter is added just for the request to the page. When you press the command button then you issue a new request that does not have a URL parameter added. To work around this, you can use a PhaseListener that stores the URL request parameter in the session for later use
Frank -
In JSP pages request.getParameter returns null
There are two jsp's,the first JSP has 1 textbox inside the form tag.We input the values in the textbox and submit.
Code :Ist jsp
<BODY>
<HEAD>
function validate()
document.add.submit();
</HEAD>
<FORM name="add" method="post" action=/dir/two.jsp" >
<TABLE width="37%" border="0" align="center" class="c4f3">
<TR>
<TD class="c4">Rating</TD>
<TD><input type=text name="rating"></TD?
</TR>
<TR>
<TD align=center><INPUT type="button" name="submitadd" value="Submit" onClick="validate()" </TD>
</TR>
</TABLE>
</FORM>
</BODY>
After the submit it goes to the 2nd JSP page .
code:2nd Jsp
<%
String Rating=request.getParameter("rating");
out.println(" Rating "+Rating);
%>
The 2nd JSP pages gets the values by request.getParameter.When I use method='post' in Ist JSP ,even if I enter values in the textbox, it prints null. But when I give method="get" , it prints the value.
Pls let me know if there is any problem in the code or its the problem due to webserver configuration.Also suggest the solution to over come this problem.
ThanksIf I'am right you have misplaced the opening body-tag of your first jsp-page.
The opening body-tag should follow after the closing head tag .
The structure of your HTML-code should look like this:
<html>
<head>
</head>
<body>
</body>
</html> -
In Portal, request.getparameter return NULL (Sample Monthcalendar)
I used the sample monthcalendar. When i used it without integrated in portal, i can change month by month with ">>" button.
In the JSP File, there is a call to the P_CALDATE parameter
String l_inputDate = request.getParameter("P_CALDATE"); // Input Date.
When i put this JSP file as an URL Portlet, i can't navigate month by month. the function request.getParameter("P_CALDATE") return NULL, but in the URL i have the parameter:
http://hddms220.cg63.fr/servlet/page?_pageid=54,58,56&_dad=portal30&_schema=PORTAL30&P_CALDATE=2002-05-01.
Someone have an idea
Thanks in advancedI have tested the sample with JSERV, and all works fine.
But if i wan't use OC4J/ORION to display a portlet how can i do it.
Thanks in advanced -
Hello Experts,
I am sending a data from one jsp page to another using java script (document.form.txtbx.value = myData), on same page I cheked and got the correct value but on the next page, I am getting null vaues. I am giving my code just check out and give me suggetions..
On button click I am calling function jfun_submit(..,..,..,..)
function jfun_submit(mhCd , scheme , dhCd , dhnm , total , grantNo , noOfBill ,grossAmt , n_p , totAMT , dept , c_v , type , grossAmtQtr , addAmount , LOC , flagnext , neg_flg , neg_amt_alwd,tansend,appNosend,appDatesend , loc)
var getLink =mhCd+"|"+scheme+"|"+dhCd+"|"+total+"|"+grantNo+"|"+noOfBill+"|"+grossAmt+"|"+n_p+"|"+totAMT+"|"+dept+"|"+ c_v+"|"+type+"|"+grossAmtQtr+"|"+addAmount+"|"+"Budget"+"|"+flagnext+"|"+neg_flg+"|"+neg_amt_alwd+"|"+loc+"&Tan="+tansend+"&AppNo="+appNosend+"&AppDate="+appDatesend;
document.bill.getLink.value= "";
document.bill.getLink.value = getLink; //setting the value to the txtfield
alert("After Set : "+document.bill.getLink.value); //shows alert correctly.
var url="BillSchemeCheckX.jsp
document.bill.action=url;
document.bill.method="POST";
document.bill.submit();
{code}
and on next jsp page me writing following code
{code}
String getLink = request.getParameter("getLink");
out.println("GetLink Value : "+getLink);
{code}
the result displying GetLink value : null
Please help me outWhat is the html for the formfield 'getLink'? I am guessing you have the id parameter set which makes this bit work 'document.bill.getLink.value = getLink;' but you dont have the name parameter set so your request.getParameter isnt working.
-
Submitting request.getParameter value on page submit
I am getting the value from the request parameter as under
<%
String mod = request.getParameter("mod");
%>
Now i want this mod value to be submitted as page submits. For that i used:
<h:inputHidden id="mod_field" value="" />
Now the question is how to pass the above mod value using this hidden input? and secondly how to bind it with the property in the backing bean (say the name of my backing bean is bean.navigation) so that i can access and use the value.Hay this exception has again started showing me up.
exception
org.apache.jasper.JasperException: javax.servlet.jsp.JspException: javax.faces.FacesException: javax.faces.el.ReferenceSyntaxException: param.mod
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)
com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:147)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
root cause
javax.servlet.ServletException: javax.servlet.jsp.JspException: javax.faces.FacesException: javax.faces.el.ReferenceSyntaxException: param.mod
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:854)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)
org.apache.jsp.tsheetRcode_jsp._jspService(tsheetRcode_jsp.java:344)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)
com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:147)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
root cause
javax.faces.el.EvaluationException: javax.faces.FacesException: javax.faces.el.ReferenceSyntaxException: param.mod
com.sun.faces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:206)
com.sun.faces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:154)
javax.faces.component.UIOutput.getValue(UIOutput.java:147)
com.sun.faces.renderkit.html_basic.MenuRenderer.getCurrentSelectedValues(MenuRenderer.java:670)
com.sun.faces.renderkit.html_basic.MenuRenderer.renderOption(MenuRenderer.java:549)
com.sun.faces.renderkit.html_basic.MenuRenderer.renderOptions(MenuRenderer.java:525)
com.sun.faces.renderkit.html_basic.MenuRenderer.renderSelect(MenuRenderer.java:481)
com.sun.faces.renderkit.html_basic.MenuRenderer.encodeEnd(MenuRenderer.java:430)
javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:712)
javax.faces.webapp.UIComponentTag.encodeEnd(UIComponentTag.java:616)
javax.faces.webapp.UIComponentTag.doEndTag(UIComponentTag.java:539)
com.sun.faces.taglib.html_basic.SelectOneMenuTag.doEndTag(SelectOneMenuTag.java:505)
org.apache.jsp.tsheetRcode_jsp._jspx_meth_h_selectOneMenu_0(tsheetRcode_jsp.java:449)
org.apache.jsp.tsheetRcode_jsp._jspService(tsheetRcode_jsp.java:263)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)
com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:147)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:198) -
Servlets, request.getParameter()
How do I test a servlet in Jdeveloper
that wants a param from the calling URL, like
http://.../servlet?myparam=myvalue
via
val=request.getParameter("myparam");
I did already figure out, how to get init-Parameters, from
webtogo.ora
with
getInitParameter();
but that is not what I want, I want normal
parameters.
Running my servlet within jdev pops up
a page with WebAppRunner.html in my Browser,
that calls the servlet in jdev, I even tried handcoding my param there with no succes
so far.
Thanks for any help in advance.
Rx
nullHi Ganesh,
Rx can u help me out on this.
I have an applet that access a servlet and fetches information
via a vector. The applet also sends the information via vector
back to the Servlet. But the servlet fails to write into the
database.
Thanks in advance!!!Thank you for your confidence,
I'm sorry for not being able to answer your question right away.
* You might post some code examples,
hopefully reduced to the minimum of what is
needed to understand your problem.
* You should consider opening a new thread
as your problem seems only loosly related
to mine.
* I am just an Oracle JDeveloper user having
gained some experience with jdev and the bc4j framework, but without the insight
of the sourcecode.
* You can however expect the people from
the Oracle JDeveloper Team to be more
responsive to user questions. - My general
experience is, that the responsiveness
in open source projects forums/mailing lists/newsgroups is much better. - They should be interested in their user's problems.
Rx
null -
JSP request.getParameter bug
i try the following code for receive Parameters from jsp.
<% String name=request.getParameter("Name"); %>
but when Name TextField(in HTML) is empty and i want to check
for none empty field with (if) instruction with following code..
if(name ==null ) //somecodes..
this instruction not run and programs continue .It's not a bug.
<%
String name=request.getParameter("Name");
if (name == null) {
//what to do if parameter does not exist
//e.g.: a checkbox not checked
} else if (name.trim().equals("")) {
//what to do if parameter exists but is 'empty'
//e.g.: an text input field with no non-whitespace characters
//NOTE: if you want leading and trailing spaces to be
// considered values, remove the .trim() from the condition
} else {
//there is a value.. do with it as you will
%> -
Jsp request.getparameter doesn't get querystring values
We have recently deployed our jsp application which was running successfully on ias8i apache jserv into the 8.1.7 JVM and configured the mod_ose on the Oracle HTTP server every thing seems to be fine except the following case.
Here we are accepting the userid,password from a jsp and submiting to the same jsp for action on submit we are reading a combination of jsp form feilds and url querystrings strangely we are able to get values only for the form feilds and querystrings return null.
The same peice of code works fine on apache jserv implementation.
Any clues please write to me.
<SCRIPT Language="JavaScript">
function check_password()
document.Login.action ="problem.jsp?tab=YES&nSessionId="+document.Login.sessionid.value+"&nUserId=" + document.Login.userid.value;
document.Login.target = "_top";
document.Login.method = "post";
document.Login.submit();
</SCRIPT>
<%
userid = request.getParameter("userid");
password = request.getParameter("password");
tab = request.getParameter("tab");
%>
<form name="Login" Border="0" TopMargin="0" LeftMargin="0" Marginheight="0" Marginwidth="0">
<table>
<tr>
<td class="FORMHEADERLEFTB"><b> Login</td>
<td class="FORMHEADERLEFT">:</td>
<td><input TYPE="TEXT" NAME="userid" SIZE="25" VALUE="<%=userid%> MAXLENGTH="10"></td>
</tr>
<tr>
<td class="FORMHEADERLEFTB"> Password</td>
<td class="FORMHEADERLEFT">:</td>
<td><input TYPE="password" NAME="password" SIZE="25" VALUE="<%=password%>" MAXLENGTH="10" onChange="check_password()"></td>
</tr>
</table>
<input type="hidden" name="sessionid" value="999999">
</form>
Thanks
suresh
nullHow are you retrieving the parameter values? I am able to retrieve parameters successfully using the following simple testcase:
untitled1.jsp:
<form method="post" action="servlet1">
<P>Username:
<input type="text" name="un"/>
</P>
<P>Password:
<input type="text" name="pw"/></P>
<P>
<input type="submit" value="Submit"/>
</P>
</form>
servlet1.java: (copy and paste from doGet() to doPost() method depending on value of form method in untitled1.jsp)
String un = request.getParameter("un").toString();
String pw = request.getParameter("pw").toString();
out.println(un);
out.println(pw);
Please test this and let me know your results and the differences with what you are trying to do.
Regards,
Lynn
Java Tools Team -
Newbie request.getParameter(String) issue
I'm having an issue setting a boolean value in a bean based off a string from request.getParameter(). I've created a small example to illustrate what I want to happen:
testForm.jsp:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"/>
<title>testForm</title>
</head>
<body><form method="POST" action="testWork.jsp">
<input type="hidden" name="hiddenTest" value="1"/>
<input type="submit" name="submitTest" value="Submit"/>
</form></body>
</html>testWork.jsp:
<jsp:useBean id="test" scope="session"
class="thistestapp.testClass"/>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"/>
<title>testWork</title>
</head>
<body>
<%
out.print("<p>" + request.getParameter("hiddenTest") + "</p>" );
// Great it's sending "1"
test.setTestB(request.getParameter("hiddenTest"));
//So when I set this in the bean I should get true
out.print("<p>" + test.getTestB() + "</p>" );
//False? Not nice!!
test.setTestB("1");
//Alright there must be an issue with my code in the bean, so hardcode a
//"1" in. I should still get false.
out.print("<p>" + test.getTestB() + "</p>" );
//True?? I hate you.
%>
</body>
</html>testClass.java:
package thistestapp;
public class testClass {
private Boolean testB;
public void setTestB(String testB) {
if ( testB == "1"){
this.testB = true;
else{
this.testB = false;
public Boolean getTestB() {
return testB;
}So, I want when the bean is sent a "1" from the form to set the bean value to true. I however can't get that to happen. I'm sure there's something I'm missing.
TIA.
Joe? if ( testB == "1"){
Standard beginner's error. If you want to test if two strings contain the same text, use the equals() method. Like this:if ( testB.equals("1")){Your code tests whether the two sides of the == operator refer to the same object. It's possible and likely for two different strings to contain the same value, which is what you are really interested in. -
Unable get complete filepath from jsp page using request.getParameter()
Hey all,
i am actually trying to get the selected file path value using request.getParameter into the servlet where i will read the (csv or txt) file but i dont get the full path but only the file name(test.txt) not the complete path(C:\\Temp\\test.txt) i selected in JSP page using browse file.
Output :
FILE NAME : TEST
FILE PATH : test.txt
Error : java.io.FileNotFoundException: test.txt (The system cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:106)
at java.io.FileReader.<init>(FileReader.java:55)
at com.test.TestServlet.processRequest(TestServlet.java:39)
at com.test.TestServlet.doPost(TestServlet.java:75)
JSP CODE:
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>DEMO SERVLET</title>
</script>
</head>
<body>
<h2>Hello World!</h2>
<form name="myform" action="TestServlet" method="POST"
FILE NAME : <input type="text" name="filename" value="" size="25" /><br><br>
FILE SELECT : <input type="file" name="myfile" value="" width="25" /><br><br>
<input type="submit" value="Submit" name="submit" />
</form>
</body>
</html>
Servlet Code :
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException, FileNotFoundException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
try {
String filename = request.getParameter("filename");
out.println(filename);
String filepath = request.getParameter("myfile");
out.println(filepath);
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet TestServlet</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Servlet TestServlet at " + request.getContextPath() + "</h1>");
if (filepath != null) {
File f = new File(filepath);
BufferedReader br = new BufferedReader(new FileReader(f));
String strLine;
String[] tokens;
while ((strLine = br.readLine()) != null) {
tokens = strLine.split(",");
for (int i = 0; i < tokens.length; i++) {
out.println("<h1>Servlet TestServlet at " + tokens[i] + "</h1>");
out.println("----------------");
out.println("</body>");
out.println("</html>");
} finally {
out.close();
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
Needed Output :
FILE NAME : TEST
FILE PATH : C:\\Temp\\test.txt
Any suggestions Plz??As the [HTML specification|http://www.w3.org/TR/html401/interact/forms.html] states, you should be setting the enctype to multipart/form-data to be able to upload files to the server. In the server side, you need to process the multipart/form-data binary stream by parsing the HttpServletRequest#getInputStream(). It is a lot of work to get it to work flawlessly. There are 3rd party API's around which can do that for you, such as [Apache Commons FileUpload|http://commons.apache.org/fileupload] (carefully read the User Guide how to use it).
You can also consider to use a Filter which makes use of the FileUpload API to preprocess the request so that you can continue writing the servlet code as usual. Here is an example: [http://balusc.blogspot.com/2007/11/multipartfilter.html]. -
In WL6.1 request.getParameter returns NULL for URL parameters that exist
With the following URL, I get different results between WebLogic 4.5.1 and WebLogic
6.1:
http://phx-kmccarthy.medspecialists.net/tsweb/ParametersTest.jsp?apple=macintosh&tree&dog&country=USA
Weblogic 6.1 returns:
query string = apple=macintosh&tree&dog&country=USA
apple = macintosh
tree = null
dog = null
country = USA
WebLogic 4.5.1 returns:
query string = apple=macintosh&tree&dog&country=USA
apple = macintosh
tree =
dog =
country = USA
here is the jsp...
<%--
* ParamtersTest.jsp which shows that empty parameters are ignored in WebLogic
6.1
--%>
<%
String apple, tree, dog, country;
apple = request.getParameter("apple");
tree = request.getParameter("tree");
dog = request.getParameter("dog");
country = request.getParameter("country");
out.println("<br>query string = " + request.getQueryString());
out.println("<br>apple = " + apple);
out.println("<br>tree = " + tree);
out.println("<br>dog = " + dog);
out.println("<br>country = " + country);
%>
From the documentation on the getParameter() method:
Returns the value of a request parameter as a String, or null if the parameter
does not exist.
In my opinion, not existing and being empty are different. Also, every other web
application environment we've dealt with (including WebLogic 4.5.1) treats them
as different. If the parameter doesn't have a value, (i.e. ...&tree&dog&...) then
getParameter() returns the empty string, not null.
As a result of this we have JSPs that break when running on 6.1.
Found the solution at last. Tomcat servlet container can't handle the chunked transfer-encoding that the J2ME Wireless Toolkit uses when you call outputstream.flush() in midlet. Using outputstream.close() instead of outputstream.flush() will avoid this problem for small requests. For all the codes in the articles on Http Post in Wireless Forum, don't use outputstream.flush() and it will run perfectly - Servlet's request.getParameter(parameterName) will work fine in doPost method.
-
Getting chinese charaters from Form using request.getParameter()
Hi,
I want my JSPs to be unicode enabled. In HTML forms user can enter any characters like japnese, chinese etc. But on the server side if user enters any such characters i am getting decimal equivalent of that character in the form of &#{decimal equivalent}; in the request.egetParameter() method.
For ex if I enter �覢覣觇觉訅 then i get "╢&# 35234;&# 35235;&# 35271;&# 35273;&# 35333;" in request.getPrameter().
I have given the charset "UTF-8" in the header of my JSPs.
I tried to decode it with URLDecoder but it fails then i tried to read these parameters using reader but it also fails, then
String para = request.getParameter("para"); // where para is name of received parameter
byte[] bytes = para.getBytes();
para = new String(bytes, "UTF-8");
This also fails.
Can anyone please tell me how to handel this problem?
Thanx
-VaijayantiHi,
I have tried this in my jsp and it works for me, assuming that the form is submitted with encoding UTF-8 :
Submitting JSP :
<form action="test.jsp">
<input type="text" name="a">
</form>
This is test.jsp :
<%
String a = new String (request.getParameter ("a").getBytes (), "UTF-8");
%>
Passed Parameter = <%=a%>
Hope that helps
Thanks
Amit
Maybe you are looking for
-
Upon each opening firefox 4.0, a dialog box opens asking to install a critical update. Upon proceeding, the script runs but nothing happens. Is it may be a virus dumping data to offsite location? Mitch
-
How do I change the name of my Mac
How do I change the name of my Mac
-
How to change an after login page?
Does anyone knows how to change an after login page from a default page 1 to, let's say page 200?
-
Hi Experts, I have a requirement of achieving SSO in MDM EP implementation.I have my portal and MDM configured to LDAP.Now my questions are a)Does trusted connection API work fine with LDAP user in MDM.I mean say if user is XYZ in LDAP then if I pass
-
Starting and Stopping Services Based on Network
Hi everyone, This is something I've been playing with and I'd like to share it with you and get your thoughts. The services I want to run at any given point depend on what network I'm attached to. For example, if I'm at home, I'll want avahi-daemon a