• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Needed a logic?

 
Kartik Tal
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my JSP page am having two links called "LINK1" and "LINK2".

On click of LINK1 am displaying one DIV1 tag, where as on click of second link am disabling first DIV1 and activating second DIV2. This one am able to achieve by using javascript.


But the problem is on click of second link am calling a javascript where am enabling the DIV2 and also am submitting the page where am interacting with DB and the values should be displayed back to my JSP with enabling the DIV2.

How can I achieve this?
 
Vijitha Kumara
Bartender
Posts: 3914
9
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From Javascript you can submit the form (not sure this is what you looking for) using,

And if you need to enable DIV2 do it in the "onload" of the form by calling a JS function.
 
Kartik Tal
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vijitha,
This is not am asking for, am asking like when am submiting the page am doing some logic where the result of that logic
am transferring to same JSP.
At that time i need DIV2 to be displayed with the results.
 
Vijitha Kumara
Bartender
Posts: 3914
9
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can set the data as attribute of one of the scopes (request,session etc..) as appropriate and also a flag (which you can use to decide whether to dispaly data or not).
 
Vaib Gupta
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
May be you will have to include some server side code in this. First time when you load the page neither of your divs are visible. Some flag can be set which is initially false for both the divs. Once you open DIV2 and submit the page pass one request attribute after hitting the DB which jsp can read and display the div.
May be something like:

<div style="display: <%=request.getAttribute('someFlag') %>" >....</div>

I am not sure of the syntax though but something like this might work.
 
Muthukrishnan Manoharan
Ranch Hand
Posts: 91
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or you can use AJAX to send data to the server and interact with db and on return back display the same in the div2 without page refresh..
 
Kartik Tal
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Muthukrishnan ,
Thanks for the suggestion, I have already opted for this. But am having a small problem with Ajax like


In my application we are keeping Headers info also in REQUEST, so while fetching back the results am getting my results+Header info, so is there any chance to divide them.
 
Muthukrishnan Manoharan
Ranch Hand
Posts: 91
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why dont you make an XML or JSON object of the response, so that you can make a clear distinction between the header information and your actual response information
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65118
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please take the time to choose the correct forum for your posts. This forum is for questions on JSP. For more information, please read this.

This post has been moved to a more appropriate forum.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65118
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please be sure to take the time to compose descriptive subjects for your posts; read this for more information.

A title such as "Needed a logic?" is not helpful. What would happen if all posts had such a title?

Please go back and change your post to add a more meaningful subject by clicking the button on your post.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65118
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kartik Talasu wrote: [/code]In my application we are keeping Headers info also in REQUEST, so while fetching back the results am getting my results+Header info, so is there any chance to divide them.

Why? This seems like a rather odd thing to do.
 
chaitanya karthikk
Ranch Hand
Posts: 806
Java MySQL Database Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi kartik, don't go with innerHTML. Why because it works only with IE. When using chrome or firefox or any other browser it wont work.
 
Peter Jennings
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
anusha chaitanya wrote:Hi kartik, don't go with innerHTML. Why because it works only with IE. When using chrome or firefox or any other browser it wont work.


Not quite.

Check W3C DOM Compatibility

innerHTML works on most browsers and it is faster in most cases. IE and Konqueror have issues with tables.

There are debates about whether to use it or not, but not because it is only IE compatible. That was true in 1996, but things have moved on a bit.
 
chaitanya karthikk
Ranch Hand
Posts: 806
Java MySQL Database Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Peter Jennings, I'm sorry, I checked it, it is working in chrome also, I read in a forum that it wont work, but I have tried it, it's working fine on chrome also. Thanks for correcting me.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic