File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Pass Parameter Via Anchor Tag in Servlets

 
Aniketh Narayanan
Greenhorn
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to pass the selected data by the user via parameter, but i am not able to get the coding right.

For example,
If the user selects ID 101, then 101 should be sent via parameter to a designated page.

The servlet code written by me is as follows:



The parameter being passed by writing the above code is: EID=rs.getString(1).
I dont want that. I want the String passed by ResultSet to be passed.

Please help.
 
Akhilesh Trivedi
Ranch Hand
Posts: 1599
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This looks too complicated, because your database, your view and your control-logic all are in one place. Why not have JSP separately and send/receive data via session/request objects.
 
Aniketh Narayanan
Greenhorn
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Akhilesh Trivedi wrote:This looks too complicated, because your database, your view and your control-logic all are in one place. Why not have JSP separately and send/receive data via session/request objects.


Even if a JSP is separately created, how will i write the code to display the database in a tabular column.
And how will i retrieve the CLICKED value in parameter ?

 
Akhilesh Trivedi
Ranch Hand
Posts: 1599
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSPs strength is in scriptlets. Or even better you can use tag-libraries, to start with servlets/jsp you may use this book.

Aniketh Narayanan wrote: Even if a JSP is separately created, how will i write the code to display the database in a tabular column.


Come up with whatever you are doing and I am sure you will get help from this forum.
 
Akhilesh Trivedi
Ranch Hand
Posts: 1599
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://www.roseindia.net/jsp/forloopjsp.shtml
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64182
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Akhilesh Trivedi wrote:JSPs strength is in scriptlets.

No, it is not! Scriptlets have been obsolete for over 10 years. They should not be used in modern JSP.

JSTL and EL are the moderne work-horses of JSP.
 
Akhilesh Trivedi
Ranch Hand
Posts: 1599
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:JSTL and EL are the moderne work-horses of JSP.


What is JSTL?
 
Darlan Moraes
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is a library that you could add to your project.
This library is very useful for working with JPSs.
For example, on your Servlet, you could have:



... forward to a JSP...

Then in your JSP:



http://www.tutorialspoint.com/jsp/jsp_standard_tag_library.htm
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64182
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Akhilesh Trivedi wrote:
Bear Bibeault wrote:JSTL and EL are the moderne work-horses of JSP.


What is JSTL?


JSTL
 
Akhilesh Trivedi
Ranch Hand
Posts: 1599
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is what i had said earlier...

Akhilesh Trivedi wrote:JSPs strength is in scriptlets. Or even better you can use tag-libraries...


 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64182
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Akhilesh Trivedi wrote:That is what i had said earlier...

Akhilesh Trivedi wrote:JSPs strength is in scriptlets. Or even better you can use tag-libraries...



There is no "strength" in scriptlets. They are obsolete and should not be used.
 
nalla srinivas
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please remove \(slash) before url. i think i will work
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64182
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
nalla srinivas wrote:please remove \(slash) before url. i think i will work

There is no \ in the URL -- that's an escape character in the Java string literal.
 
Hikari Shidou
Ranch Hand
Posts: 88
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Aniketh Narayanan wrote:



rs.getString(1) is inside a string, therefore it's not processed as Java code. You must move it out of the string...
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic