• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java Script in JSP page

 
vanaja konda
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am using JavaScript to pop up a window in JSP page.

Following in my JavaScript function

function openSizedDialog(url, dialogName, width, height){

var style=new String();

style="toolbar=no, directories=no, location=no, status=no, menubar=no, resizable=no, scrollbars=yes,";

style+="width="+width;
style+=", height="+height;

var dlg=openWindow(url, dialogName, style);

}

function openDialog(url, dialogName){
var dlg=openSizedDialog (url,dialogName,800,600);
}

function openWindow (url, name, style){
var wnd=window.open (url, name, style);
}

When giving in the JSP page if I give like this

<td><a href="javascript penDialog('/Generalconfig.jsp','GeneralConfiguration');">General Configuration</a></td>

it says /Generalconfig.jsp not available. I am using Tomcat as my application server. (I got this message on the pop up window itself)
It is looking for that JSP page under ROOT folder of Tomcat.
When I copied the file under the ROOT it was able to find it and I got the jsp page to be popped up.

But I really dont want to this(copying JSP pages under ROOT folder)

Can you let me know how can I avoid this?

Appreciate if anyone could help me
Thanks
Vanaja
 
sweta naidu
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you checked by replacing '/Generalconfig.jsp' with Generalconfig.jsp.
 
vanaja konda
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Thanks for the reply.
Yeah, I have checked that way. It didnt work.

It only works when I give /ProjectName/jsp/Admin/Configuration/Generalconfig.jsp. (both the jsp's are under the same folder. The jsp to be popped up and the jsp where there should be a link to be popped up.

But I really dont want to include the project name in path.

Appreciate if anyone could help me. It has been more than a day I am struck up here.

I tried to write a simple action class and point it to that jsp to be popped up but it didnt work that way either.

Thanks again
Vanaja
[ July 28, 2005: Message edited by: Vanaja Kommera ]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65522
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This has nothing to do with the Javascript on your page but rather the structure of your web app.

Where is the context root of your web application?
Where, in relation to that root, is the JSP file located?

That will determine what the URL has to be.
 
vanaja konda
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
Thanks for the reply.
I am not sure what url to specify.

Here is the structure of my web app


[ July 28, 2005: Message edited by: Vanaja Kommera ]


Appreciate if anyone could help me.
Thanks again
Vanaja
[ July 28, 2005: Message edited by: Vanaja Kommera ]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65522
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your chart did not help me understand the folder layout of your application.
 
vanaja konda
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have edited again. I am new to the forum any better way to show the folder structure??
Thanks
Vanaja
[ July 28, 2005: Message edited by: Vanaja Kommera ]
 
vanaja konda
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am showing my folder structure again

Tomcat/webapps/ProjectName/jsp/Admin/Configuration/(The jsp where there is a link for popup and the jsp which should popup are here

Tomcat/webapps/ProjectName/WEB-INF/classes
Tomcat/webapps/ProjectName/WEB-INF/tld
Tomcat/webapps/ProjectName/WEB-INF/lib
Tomcat/webapps/ProjectName/WEB-INF/struts-config.xml
(of course web.xml and validator.xml are also in WEB-INF)
Appreciate if anyone could help me.
Thanks in Advance
Vanaja
[ July 28, 2005: Message edited by: Vanaja Kommera ]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65522
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then the path would be

"/jsp/Admin/Configuration/Generalconfig.jsp"

If you want it to be something different, you'll either need to move the JSPs or start doing some fancy mapping in the deployment descriptor.

Why would you want it to be something different?
 
vanaja konda
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Thanks for your reply.

I tried to give

<a href="javascript penDialog('/jsp/Admin/Configuration/GeneralConfig.jsp','GeneralConfiguration');">General Configuration</a></td>

I get the pop up but with the following error report.


Status report

message /jsp/Admin/Configuration/GeneralConfig.jsp

description The requested resource (/jsp/Admin/Configuration/GeneralConfig.jsp) is not available.


It only works if I give /PROJECTNAME/ before '/jsp/Admin/Configuration/GeneralConfig.jsp' as

/PROJECTNAME/jsp/Admin/Configuration/GeneralConfig.jsp'

It even doesnt work if I dont specify "/" before the PROJECTNAME as

PROJECTNAME/jsp/Admin/Configuration/GeneralConfig.jsp'

It is not a good idea to include PROJECTNAME in path. So I want to avoid giving the project name in path.

I guess it is looking for the URL after the

http://localhost:8080

Any idea what is happening and where I am doing wrong?

Appreciate your quick reply and hopefully something will work out.

Thanks
Vanaja
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
request.getContextPath() will get you the name of your application.
Prepend that to the URL instead of hardcoding it.
 
vanaja konda
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Thanks for your reply,

I tried to give



It is not able to find it again.

Appreciate if anyone could help me.

Thanks
vkr
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65522
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah, something I read in an earlier post led me to think that this app was loaded into the default context. Since it is not, the context path must be included. (Aside: bear kicks self in butt since assuming that an app is in the default conetext is just as bad as hard-coding the context path and I should have mentioned that right off the bat).

Try:



The fact that you didn't know to enclose the method invocation in the appropriate JSP tag markup tells me that you really ought to consider taking a JSP tutorial before proceeding any further. This is a very basic concept that will trip you up badly if your are working with JSPs and do not understand it.
[ July 28, 2005: Message edited by: Bear Bibeault ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!