Passing Parameter to own page

Posted on 2005-03-19
Medium Priority
Last Modified: 2010-04-01
Dear friends,

I two have a jsp page. One is news.jsp and the other is news1.jsp. news.jsp contains a form that passes two parameter to news1.jsp.One the other hand news1.jsp contains the same form of news.jsp that passes these 2 parameter to itself. The reason i m doing this is because i m using a web pager that displays all record on news.jsp page and on news1.jsp page display a range of date selected by the user.

I declare it as:
String start_date = request.getParameter("st_date");
String end_date = request.getParameter("en_date");

My problem is when i pass the start date and end date to news1.jsp from news.jsp, the page will display only 10 records as i want ranging from the date chosen. However when i click next, the start_date and end_date becomes null value, and causes my ResultSet to pass null value to the function and this cause a SQL error. How can i possible solve this logic ?

ResultSet rs_viewSelectedNews1 = dbconnect.viewNewsByDate(start_date,end_date);
this line pass null value when i click on next. To retrieve next 10 records.
Question by:williamlcs82
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
LVL 29

Accepted Solution

bloodredsun earned 1000 total points
ID: 13583405
When you create the next link, make sure that you pass the parameters in it.
e.g. where you are specifiying an offset of 10.

<a href="news1.jsp?offset=10&st_date=<%=request.getParameter("st_date")%>&en_date=<%=request.getParameter("en_date")%>"> click here for next</a>

Expert Comment

by:C TG
ID: 13589169
I think Bloodredsun solution, is not the most aproprate, here ... You're using forms, so ... You need extra Java script .... to do the submit ....

1. You should use session. Put the date variables in session, and than you'll be able to access them without resending in every page.

2. You must resend the values to news1.jsp itself. So to do that I recomend using hidden fields in forms. So, in the form form news1.jsp you will put two fields, like:
<input type="hidden" name="st_date" value="<%=request.getParameter("st_date")%>">
<input type="hidden" name="en_date" value="<%=request.getParameter("en_date")%>">
Those two fields, won't even appear as form elements in the browser (If you're not familliar with HTML froms), they're hidden.

3. To be more apropriate to his solution ...
If you use the POST method ... than you can modifie the action like:
<form name="..." action="news1.jsp?offset=10&st_date=<%=request.getParameter("st_date")%>&en_date=<%=request.getParameter("en_date")%>" method="post" ... >
Be sure to use POST if u use this kind of  solution  ..., On GET method of submit, the extra parameters from action, will be loose.

Hope it helps ...


Expert Comment

by:C TG
ID: 13589193
Sorry, maybe I wasn't clear enough. There are 3 solutions ... No need, to use them all. I think the best to use can be the second one, with hidden form fields.

LVL 29

Expert Comment

ID: 14232360
I'm happy with this :-)

Featured Post


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Cyber News Rundown brings you the latest happenings in cyber news weekly. Who am I? I’m Connor Madsen, a Webroot Threat Research Analyst, and a guy with a passion for all things security. Any more questions? Just ask.
In the absence of a fully-fledged GPO Management product like AGPM, the script in this article will provide you with a simple way to watch the domain (or a select OU) for GPOs changes and automatically take backups when policies are added, removed o…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

741 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question