Have a look at the request dispatcher.
To implement it the code will look something like this:
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/Homepage.jsp");
dispatcher.forward(request, response);
Have a look at the request dispatcher.
To implement it the code will look something like this:
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/Homepage.jsp");
dispatcher.forward(request, response);
A trip to the mall did me well :)
I was just using the wrong method i was supposed to do this:
if ((jo.get(dDate) instanceof JSONObject)){...
its working now yay :icon_smile:
Hi
I have been struggling with this for some time now, and am not sure what is wrong.
I am using the org.json package
I have this json String which looks like this:
{"2009-08-04":[{"Status":"1","Description":"sdfsdf","Task Name":"task 2","TaskId":"2"},{"Status":"1","Description":"testing 3","Task Name":"testing 3","TaskId":"3"}],"2009-07-31":{"Status":"1","Description":"read POC","Task Name":"task 1","TaskId":"1"}}
As u can see the one object is actually a json array. What i wanted to do is check whether the object is a json array or an object, then display them in a table.
But while iterating through the object the objects class is a String thus making it impossible for me to check whether it is a json array or a json object.
Iterator itr = jo.sortedKeys();
while (itr.hasNext()){
Object obj = itr.next();
System.out.println(obj.getClass());
}
Any ideas how i can differentiate once inside the iterator?
Do u have to use javascript? I think CSS would be a much better choice.
If the redirect is to look like this
response.sendRedirect("welcome.jsp?name="+userName);
then to get the username from the query string you would use it just as u did earlier (from your original post "String userName = ......") , like this:
<%=request.getParameter("name")%>
Daughtry - Leave this town (album)
Eminem - Relapse
Sergio Mendes
I am new to jsp but I would do either one of the following:
1. Set the username as a session variable and then in welcome.jsp u can use
<%=session.getAttribute("userName")%>
2. Send the username in the querystring when redirecting to the welcome page then just use
request.getParameter("userName")
to display it.
I would normally declare it like just after the main class, like this:
public class Demo1 extends JFrame implements ActionListener, ItemListener
Demo1 {
[B]String string1 = "here";[/B]
..............................
public JPanel MyPanel() {
Action a1 = new AbstractAction("Some Action")
{
public void actionPerformed(ActionEvent e)
{
System.out.println(string1);
}
}
}
.....
class Class2 implements TreeSelectionListener
{
public void valueChanged(TreeSelectionEvent event) {
// assigning some value to string1
}
}
} // End of constructor Demo1
Hi
In am new to developing web applications using java and jsp's, and after a strange problem i encountered was wondering how does the url get populated with the path of the file sometimes and not at other times.
Lets say in my web.xml in the welcome-file parameter, the path specified is pages/hello.jsp. From what i understood, when going to the web apps url for example http://localhost:8888/helloapp/ which will then redirect to the hello.jsp page, would the url in the browser reflect that and the url in browser than would be http://localhost:8888/helloapp/pages/hello.jsp ?
Does url "display" get configured depending on the application server used?
Kind regards,
T
Your code looks correct, theoretically it should work, but i see now that u cannot click on the google link, will try and figure out why that is happening.
The container id in your css is causing the problem. I am no genius in css, but i think what is happening is that the container id has a height of 530px, which then covers the area where the google link is, so your text appears under that "layer" thus it is not rendered correctly.
I removed the height attribute from container, so the container id looks like this:
#container {
margin : 55px 0 15px 0;
position : absolute;
width : 760px;
}
And the link shall now work in firefox.
Thanx, for the help, i have just changed all the references to the directory structure to the absolute values and they seem to be working, changed code to look like this
<script type="text/javascript" src="/main/mainapp/scripts/xxx.js"></script>
I think when running the file on a server and if the full path isnt displayed in the url, somehow the referenced files cannot be found. I could be wrong, although i remember a long time ago when i just started developing in html someone telling me to better use full paths and not directory structures.
Thanx again.
<head>
<title>Web API</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></meta>
<script type="text/javascript" src="../../mainapp/scripts/xxx.js"></script>
<script type="text/javascript">
// Construct eMap object with servlet context, and destination div for map
//var eMap = new eMap("/mainapp/BasicMapExample", "mainMap");
var contextRoot = '../../';
// Create mainapp Map object
var eMap = new eMap(contextRoot, "mainMap");
ESEvent.addListener(eMap, ESEvent.onInit, onMapInit);
ESEvent.addListener(eMap, ESEvent.onClearSelection, onClearSelection);
window.onload = function(){
// Init eMap object with mapName
eMap.init("Africa Map");
}
var layerControl = new LayerControl(eMap);
var infoControl = new InfoControl(eMap);
var zoomControl = new ZoomControl(eMap);
function onMapInit(){
zoomControl.showRQ();
infoControl.loadRQ();
}
</script>
<style type="text/css">
<!--
/* BEGIN PAGE LAYOUT */
#LogoItemLeft {top:55px; left:100px; position:absolute;}
#navigationPanelHead {top:35px; font-size: 12px; font-family: verdana, helvetica, sans-serif; text-align:center; font-weight: bold; color: #FFFFFF; left:655px; width:145px; background-color:#4777A5; border: 1px solid #4777A5; z-index:100; position:absolute;}
#navigationPanel {top:50px; text-align:center; padding-top:5px; left:655px; width:145px; border: 1px solid #4777A5; z-index:100; position:absolute;}
#mapPanelHead {top:90px; font-size: 12px; font-family: verdana, helvetica, sans-serif; font-weight: bold; color: #FFFFFF; text-align:center; left:100px; width:700px; background-color:#4777A5; border: 1px solid #4777A5; z-index:100; position:absolute;}
#mainMap {top:105px; left:100px; border: 1px solid #4777A5;}
/* END PAGE LAYOUT */
/* BEGIN NAV CONTROL */
#navigationControl {position:absolute; display:block; left:125px; width:60px; top: 205px; margin-top:0px; margin-left:0px; padding:0px; border: 0px solid #FF0000; z-index:8;}
#navigationControlInner {display:block; width: 60px; height: 185px; border: 0px #00FF00 solid;}
#navigationControlSlider {position:absolute; display:block; left:145px; width:20px; top: 340px; margin-top:0px; margin-left:0px; padding:0px; border: 0px solid #FF0000; z-index:8;}
#navigationControlSliderInner {display:block; width: 20px; border: 0px #00FF00 solid;}
div.row div {float: left;}
div.col div {width:20px; text-align:center; float: left;}
div.row div.spacer {width: 20px; height: 20px;}
div.row div.panNorth {width: 20px; height: 20px;}
div.row div.panSouth {width: 20px; height: 20px;}
div.row div.panEast {width: 20px; height: …
Can u provide an image or more detail on what isnt working correctly, cause in IE the navigation is listed vertical while in firefox the navigation is listed horizontally.
What hover isnt working correctly?
Hi
I have set up an example web app which was already written by a third party company. My problem comes in when i enter the app name like http://localhost:8080/app1/ it redirects to the correct page that was used in the <welcome-file> tag in the web.xml but the js scripts and the css file does not get loaded. But when i enter the complete path to the file the scripts and css gets loaded. So i know nothing is wrong with the page, but i have no clue how to figure out what is wrong, why doesnt the scripts load??
This app does not use struts.
If any one could please point me in the right direction, i have no idea how to even google my problem.
Thanx
Thirusha
My pleasure.
Please mark as solved if the answer solved your problem.
You would write it teh smae way you would in html. just remember to escape the double quotes in the servlet.
It should look something like this:
out.println("<a href=\"http://www.google.co.za\">google</a>);
You shouldnt be connecting to a database from a jsp page, rather use a servlet.
Have a look here http://simple.souther.us/ar01s10.html
To join two strings use the "+" sign
for example:
var str1 = "we still here";
var str2 = "where are you";
var str3 = str1 + " " + str2;
Try google to search for ways to remove spaces, there are loads of scripts on the internet.
So what is it that you dont know how to do?
Turns out it was my toad, managed to get it to work.
I m trying to execute the sdo_migrate.to_current method like this :
execute sdo_migrate.to_current('tablename');
but i keep getting invalid sql error, and i dont understand why.
Please help
That works, how do I shunt the text to the right, I need to have some space at the start at the left border so the text is over to the right a bit more.
try adding padding-left to the style attribute of the text area, something like this:
style="padding-left:5px"
Also we have the problem with this here, see image, that needs getting rid off.
[IMG]http://img217.imageshack.us/img217/4272/makehappytimes4.jpg[/IMG]
ignore the happy face, the background was for something else. as can be seen in the image, text needs shunting to the left, and the green circle shows an icon thing that needs getting rid off.
Can u include the entire code that u are using for that page, i suspect somewhere there is an comment that isnt commented properly.
try this
background-color: transparent
your textarea tag should look something like this:
<textarea style="border:none; background-color: transparent" name="results" rows="11" cols="15"></textarea>
A bit lazy arent we ??? I have some time to kill so i shall do this but it is pretty simple, all u had to do was look for the same tags that i hade given u earlier.
Replace the text in red with the text provided in my other message
<form name="lotto">
<div align="center"><center><table border="0">
<tbody><tr>
<td align="center">Pick <select name="numbercount" size="1">
<option value="1">1 </option>
<option value="2">2 </option>
<option value="3">3 </option>
<option value="4">4 </option>
<option value="5">5 </option>
<option value="6" selected="selected">6 </option>
<option value="7">7 </option>
<option value="8">8 </option>
<option value="9">9 </option>
<option value="10">10 </option>
</select> numbers<br>
from 1 through <input name="maxnum" value="49" size="2" maxlength="2" type="text"><br>
<input value="Pick Numbers" onclick="numbers()" type="button"><p><textarea name="results" rows="11" cols="15"></textarea> </p></td>
</tr>
</tbody></table>
</center></div>
</form>
Try googling "page loading", there are loads of examples available.
Why do u have two function stateChanged() and why do u have a function within a function?
I suggest get rid of the second stateChanged() function.
Download firebug for firefox, great tool for debugging.
Firstly the border that surrounded the text area is the default border visible in the browser.
To get rid of that u need to add a style attribute to the textarea tag, something like this:
<textarea style="border:none" name="results" rows="11" cols="15"></textarea>
what about putting your page behind a log on screen?
can u provide the code for the functions show_pas(), show_chil() and show_infa()
Can u provide some code.
So what u want to do is not let the header cells to stretch if u stretch the web page? or do u want the header cells to remain a constant size with the data cells stretching depending on the amount of data within those cells?
I want to develop a web app that can allow the user to change the type of database he/she is using(Access, Sql Server, Oracle), just by changing the connection properties in a properties file.
I am assuming that this is possible.
Would it become too complicated meaning way too much work(its not for a client its just for the company), if there are differences in writing the sql statements depending on which database is used?
My big plan is that the app can be used with either of the above mentioned databases just by changing the connection properties.
Not sure if i have thought about all the implications.
Any comments or suggestions will be highly appreciated.
Try googling "delete all rows of table with javascript" loads of information came from the search I did, if u get stuck with the code, place the code that you are having trouble with, and someone will definitely try and help you.
I havent used MySQL that much, but i do know that to sort results you would use the "order by" clause, a small example:
Select name, id, gender from tblPerson order by name
You can use the keyword DESC to order objects in descending order.
Why dont you split your result into an array using the split method for example :
<%
Dim DOB, MyDobArray
DOB= bdayRS.Fields.Item("dob").Value
MyDobArray = Split(DOB,"/")
%>
then you can format each area of the date because for example
MyDobArray(0) = "2009"
MyDobArray(1) = "04"
MyDobArray(2) = "23"
Another way could be to use the substring method just to get the month and then to call MonthName on the result
try googling "load an external js file". there are loads of examples on the internet.
Is there a way of changing the username and password used to connect to the db in a connection pool, or do i have to create a new connection pool with the new username and password.
I do not want to hard code the connection string thats why i want to do it with a connection pool, as teh connection pool names will not be changing, but the connection string will change when the app gets installed on different machines.
I couldnt find a way to do it, so went with teh setter and getter methods.
U are not calling your function anywhere in the html
My suggestion would be to change the submit button to a normal button and use the onclick to call teh function like this:
<input type="button" value="Submit" name="Submit" onclick="validateForm()">
I dont see the need to pass the contact variable in to the function i dont see it being used any where
Another thing u have to swop your comparisons around like this:
if(document.forms.contact.shipfirst.value == "")
{
alert("Please enter your full name.");
return false;
}
Can u provide the code that u are using
I think it would be something like this:
weekdayname(weekday(ADt))
cannot use the body onload since i am using all this inside an ajax based app.
its looking more like i will have to start typing those setter and getter methods :(
It seems the java scripting might not help, since from what i understand it is meant to use a javascript function inside the jvm, while i need to access it from servlet in a web browser. I could have understood it wrong though, if i m wrong please let me know.
Thanx am having a look at it right now, i just fear having to write a whole lot of setter and getter methods, so i hope that this will work in my app.
My head is telling me that the answer to this question is going to be NO, but hopefully i m wrong.
I have a servlet which gets redirected using RequestDispatcher to a jsp page, the jsp page has some html input fields. In the servlet i get the values from the db and can place them in a json object, and want to display those values inside the input fields. I have a javascript function that can do that by looping through a jsonObject.
The question is this, can i fire a javascript function from the servlet?
:$ Turns out it was just ajax and IE issue, so now everything is working great. just inserted a timeStamp to alll my ajax calls. :icon_smile:
:@ removing the session might not be my problem, i m not too sure what is exactly.
My app has and index page, and using ajax i navigate through to other pages, like a wizard section, my index page is never refreshed until i press the refresh page button.
I enter some values into teh first page of teh wizard, which is a jsp page, the details i entered is then set in a jsonObject in a servlet, which then redirects to another jsp page. When i write out teh jsonObject on teh jsp page it is correct(I can refresh the index page enter some new details, and the new details are displayed on that page), Now i then send that page to another servlet, and i write out teh jsonObject on that servlet, when i refresh and go through the process, in IE the first set of details i entered are being displayed in teh servlet page, while in FF the latest set of details are being displayed.
I dont know if this could be a setting in IE(i hope it is), or there is something wrong with my servlets.
Any ideas will be greatly appreciated.
Hi
I am trying to remove a session attribute from my app, currently i use the jstl tag remove to remove the attribute, this works in firefox when the browser is refreshed, but not in IE, so i then decided to use the session.removeAttribute method in a servlet that gets run before the application is viewed in the browser, and still no luck.
Does anyone have any idea how to remove the session attribute when IE is refreshed?
thanx
T