aspose file tools*
The moose likes Spring and the fly likes calling a jsp without using a controller Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "calling a jsp without using a controller" Watch "calling a jsp without using a controller" New topic
Author

calling a jsp without using a controller

Glyzel Martinez
Greenhorn

Joined: Aug 20, 2010
Posts: 2
Hi. I have a 2 JSPs.

first JSP : It is the jsp configured to call a controller onLoad or onSubmit.
- here, i will have to dynamically add new form elements such as txtbox, tablerows, checkbox, etc.
- In order to add new form elements, and assign values to it, I will need to click on a button, let's say, "add" button.
This "add" button will trigger the display of another JSP page, which I wouldn't like to pass through a controller.

second JSP : it is the jsp called from the first JSP.
- this is a "child window" which gets some data from the parent window.
- here I will need to enter the type of form element and enter the values to be assigned to it.
- after i click "OK" button, the new form shall be added to the first JSP, including the values.

It works well if I use plain JSP.
But when I integrate it with spring mvc framework, it cannot find the 2nd JSP's location. It says, not found.
Regardless if i put the absolute or relative path or just the name of the 2nd JSP.

Is it possible?
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

"pica choo",
Please check your Private Messages for an important administrative matter.


[My Blog]
All roads lead to JavaRanch
Mark Secrist
Ranch Hand

Joined: Jul 01, 2003
Posts: 89
I had written and submitted a whole different response but as I read this, it appears you may want to take a different approach. The thing that makes your requirements interesting is the parent/child relationship between the two pages. You may want to consider a different approach like using JavaScript. It doesn't sound like the second page needs to go to the server to fulfil its function so that might be a better way to do this.
Glyzel Martinez
Greenhorn

Joined: Aug 20, 2010
Posts: 2
Mark Secrist wrote:I had written and submitted a whole different response but as I read this, it appears you may want to take a different approach. The thing that makes your requirements interesting is the parent/child relationship between the two pages. You may want to consider a different approach like using JavaScript. It doesn't sound like the second page needs to go to the server to fulfil its function so that might be a better way to do this.


Hi Mark.

Yes. Currently.. I am having the parent child relationship using javascript.

Parent window - this is called by a controller.
child window - called from the parent window via javascript window.open() call onclick of a button.
I tried to put the absolute path and the relative path of the jsp page like these, but both didn't work. :
(1) window.open("/myChildWindow.jsp","childWinName", <window properties>);
(2) window.open("/WEB-INF/jsp/myChildWindow.jsp","childWinName", <window properties>);

However, maybe since i am using spring, and i have a servlet mapping *.htm for the controllers, the javascript child window does not load.

The child window appears but does not behave as i expect it.

The error says something like this : "reference not found".
The URL of the child window is : localhost://myProj/myChildWindow.jsp

usually. when i go to a page using a controller, the url would look like this :
localhost://myProj/myPage.htm

Mark Secrist
Ranch Hand

Joined: Jul 01, 2003
Posts: 89
In your first attempt, it may simply be a matter of path mapping (i.e. you have no mapping to define '/myChildWindow.jsp' as being in the real location). In your second attempt, this would fail because the user won't have direct access to any files under WEB-INF so you can't reference that way.

I haven't tried this, but you may be able to get this to come up simply by creating a mapping. For example, in Spring 3.0, you could add the following to your controller config:

Then, you could try simply referencing it in your JSP as:
window.open("myChildWindow.htm","childWinName", <window properties>);
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17259
    
    6

Out of the blue, but if you are using Spring 3.0 the MVC Namespace has a <mvc:controller> which does this trick of you map a URL, then it just passes it quickly through to a jsp page.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: calling a jsp without using a controller