I just want to check that the parameter passed to the jsp are null or not using httpcontext so how i can able to do that
case_yr = Integer.parseInt(request.getParameter("case_yr"));
sub_type_int =Integer.parseInt(request.getParameter("sub_type_int"));
String case_num = request.getParameter("case_num");
String lang_mode = request.getParameter("lang_mode");
String mobile_no = request.getParameter("caller_id");
String dialled_id = request.getParameter("dialled_id");
i want to above values are valid or not I am submitting value from xml page to jsp page and getting value in jsp using request.getparameter()
so pleaase tell how to check values are null or not and there is no sevlet only vxml page and jsp page
Use JSTL
<c:if test="${not empty case_num}">
case_num is NOT empty or null.
</c:if>
if you wanna check if the request attributes are null,just check if they are null this way
String case_num = request.getParameter("case_num");
if(case_num!=null){
//do your logic
}
else {
System.out.println("case_num is null");
}
int number ;
String num = request.getParameter(num);
if(num!=null){
number = Integer.parseInt(num);
}
else {
System.out.println("case_num is null");
}
Related
I want to change the table from the page /manager/html/sessions of Tomcat.
The jsp file for that page is tomcatpath/webapps/manager/WEB-INF/jsp/sessionsList.jsp
I want to add a new column in table which contains the path of last page which client has requested.
Ex: if the last request of client is mydom.com/path/3, I want to show in table /path/3
This is the part where are iterated all sessions
<%
for (Session currentSession : activeSessions) {
String currentSessionId = JspHelper.escapeXml(currentSession.getId());
String type;
if (currentSession instanceof DeltaSession) {
if (((DeltaSession) currentSession).isPrimarySession()) {
type = "Primary";
} else {
type = "Backup";
}
} else if (currentSession instanceof DummyProxySession) {
type = "Proxy";
} else {
type = "Primary";
}
//I have problem getting the last accessed path by client.
String lastPath = ...;
%>
//html where is printed every row with data from session
//use here <%= lastPath %>
<%
} //end of for
%>
I don't know how to extract the last accessed path.
Tomcat version: Apache Tomcat/9.0.20
I have a ppc landing page that I want to change the hidden value of a form field based on the URL parameter.
The field
<input id="Campaign_ID" name="Campaign_ID" type="hidden" value="7g012455dv5441vdf">
The URL would be something like mysite.com/?campaignidvalue=7g012455dv5441vdf
There will be other field "values" that are also based on the URL parameter, so it has to tie the "input id" (or name) to that specific value.
EDIT: There was an error in my code.
PHP would be the easiest!
<?php
if(!empty($_GET['campaignidvalue']))
{
echo '<input id="Campaign_ID" name="Campaign_ID" type="hidden" value="'. $_GET['campaignidvalue'].'"/>';
}
?>
This block will check to see if the value is passed in a GET parameter, and then echo it out into a hidden form field.
The first part:
if(!empty($_GET['campaignidvalue']))
Is checking to see if a parameter named Campaign_ID is being passed.
So your URL of:
mysite.com/?campaignidvalue=7g012455dv5441vdf
Would allow the code to continue, as it is not empty.
This section is the part that actually displays it on the page.
echo '<input id="Campaign_ID" name="Campaign_ID" type="hidden" value="'. $_GET['campaignidvalue'].'"/>';
If you view the source of the HTML page, you would see
By using this function:
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regexS = "[\\?&]" + name + "=([^&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec(window.location.search);
if(results == null) {
return "";
} else {
return decodeURIComponent(results[1]);
}
}
You'll be able to get any URL parameter by name, like so:
var cid = getParameterByName(campaignidvalue);
Then, once you have the value you can use jQuery to set it, like so:
$(function() {
$("#Campaign_ID").val(cid);
});
String a=driver.findElement(By.id(locator))).getAttribute("value");
System.out.println("the value is "+ a);
Log.info(" Required object is present in the applicaiton"+ object);
<p locale="" isnumeric="false" basetype="String" class="outputText twControl twOutputText" id="InputText12">**MANTPLAP29102014100955627**</p>
I need to get the MANTPLAP29102014100955627 value from the above HTML code.
Please help..
Use
driver.findElement(By.id(locator))).getText();
Edit
There is a difference between getAttribute and getText methods
Consider an html tag like this
<input type = "text" id = "id" name = "bird">Peagon</input>
Now using
driver.findElement(By.id("id"))).getAttribute("name") will return value as bird (which is the value of attribute 'name')
and using
driver.findElement(By.id(locator))).getText(); will return a value as Peagon (Text between the starting and closing <input> tags)
How to look for the value whether it is null or not in JSP. E.g. in below I want to check the description column in pipe table for null values.
String Query1 = "SELECT description FROM pipe where pipe_id='" + id+"' and version_id=2";
SQLResult = SQLStatement.executeQuery(Query1);
SQLResult.first();
description = SQLResult.getString("description");
if(description=="")
{
json_string=json_string+"&desc="+description;
out.println("not null");
} else
{
json_string=json_string;
out.println("null");
}
Well: if (description != null && !description.isEmpty()) ... however are you writing this code within a JSP ? That seems wrong. You should probably do this stuff within a servlet and pass the description as an request attribute to a jsp.
Or you can use StringUtils.isNotEmpty(description).
If you are really using jsp, you should store description in a request attribute and then use <c:if test="${empty description}">.
I use this personal method:
public static boolean isNullOrEmpty(Object obj) {
if (obj == null || obj.toString().length() < 1 || obj.toString().equals(""))
return true;
return false;
}
<% if(empRecNum != null && !(empRecNum.equals("")))
{
empSelected=true;
}
boolean canModify = UTIL.hasSecurity("PFTMODFY") && empSelected;
%>
<script type="text/javascript">
function add(){
alert('hello');
df('ADD');
}
</script>
On the click of add button, i need to pass the boolean value to another jsp and then go on with the df servlet function.
pass in URL like
second.jsp?param=value
access param from second jsp
request.getParameter("param");
OR:
Store it in cookie
OR:
Persist it in DB
I found this, which may help:
http://www.exampledepot.com/egs/javax.servlet.jsp/caller.jsp.html